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. // Similar to the regex found in HtmlEditorField.js / getAnchors method.
if (preg_match_all( 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, $page->Content,
$matches $matches
)) { )) {
$anchors = array_filter(array_merge($matches[3], $matches[5])); $anchors = array_values(array_unique(array_filter(
array_merge($matches[3], $matches[5]))
));
} }
} else { } else {

View File

@ -133,8 +133,7 @@ class HtmlEditorFieldTest extends FunctionalTest {
'bar', 'bar',
'baz', 'baz',
'bam', 'bam',
"some'id", "some'id",
'bar',
); );
$page = new Page(); $page = new Page();
$page->Title = 'Test'; $page->Title = 'Test';
@ -142,15 +141,15 @@ class HtmlEditorFieldTest extends FunctionalTest {
$page->write(); $page->write();
$this->useDraftSite(true); $this->useDraftSite(true);
$controller = new Controller(); $request = new SS_HTTPRequest('GET', '/', array(
$controller->setRequest(new SS_HTTPRequest('GET', '/', array(
'PageID' => $page->ID, '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() { public function testHtmlEditorFieldFileLocal() {