Fix merge regressions

This commit is contained in:
Damian Mooyman 2016-01-19 17:08:40 +13:00
parent 8c1cafd1a0
commit 8e4db95f72
2 changed files with 11 additions and 10 deletions

View File

@ -582,11 +582,13 @@ class HtmlEditorField_Toolbar extends RequestHandler {
// Similar to the regex found in HtmlEditorField.js / getAnchors method.
if (preg_match_all(
"/\s+(name|id)\s*=\s*([\"'])([^\\2\s>]*?)\\2|\s+(name|id)\s*=\s*([^\"']+)[\s +>]/im",
"/\\s+(name|id)\\s*=\\s*([\"'])([^\\2\\s>]*?)\\2|\\s+(name|id)\\s*=\\s*([^\"']+)[\\s +>]/im",
$page->Content,
$matches
)) {
$anchors = array_filter(array_merge($matches[3], $matches[5]));
$anchors = array_values(array_unique(array_filter(
array_merge($matches[3], $matches[5]))
));
}
} else {

View File

@ -133,8 +133,7 @@ class HtmlEditorFieldTest extends FunctionalTest {
'bar',
'baz',
'bam',
"some'id",
'bar',
"some'id",
);
$page = new Page();
$page->Title = 'Test';
@ -142,15 +141,15 @@ class HtmlEditorFieldTest extends FunctionalTest {
$page->write();
$this->useDraftSite(true);
$controller = new Controller();
$controller->setRequest(new SS_HTTPRequest('GET', '/', array(
$request = new SS_HTTPRequest('GET', '/', array(
'PageID' => $page->ID,
)));
$controller->init();
));
$toolBar = new HtmlEditorField_Toolbar($controller, 'test');
$toolBar = new HtmlEditorField_Toolbar(new Controller(), 'test');
$toolBar->setRequest($request);
$this->assertEquals(json_encode($expected), $toolBar->getanchors());
$results = json_decode($toolBar->getanchors(), true);
$this->assertEquals($expected, $results);
}
public function testHtmlEditorFieldFileLocal() {