mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
parent
009f2de17c
commit
6a7c1056fe
@ -76,6 +76,7 @@ class DB {
|
||||
if(isset(self::$connections[$name])) {
|
||||
return self::$connections[$name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -606,10 +606,13 @@ class HTMLEditorField_Toolbar extends RequestHandler {
|
||||
);
|
||||
}
|
||||
|
||||
// Parse the shortcodes so [img id=x] doesn't end up as anchor x
|
||||
$htmlValue = $page->obj('Content')->forTemplate();
|
||||
|
||||
// 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",
|
||||
$page->Content,
|
||||
$htmlValue,
|
||||
$matches
|
||||
)) {
|
||||
$anchors = array_values(array_unique(array_filter(
|
||||
|
@ -126,14 +126,22 @@ class HTMLEditorFieldTest extends FunctionalTest {
|
||||
if (!class_exists('Page')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
$html = '<div name="foo"></div>
|
||||
<div name=\'bar\'></div>
|
||||
$linkedPage = new Page();
|
||||
$linkedPage->Title = 'Dummy';
|
||||
$linkedPage->write();
|
||||
|
||||
$html = <<<EOS
|
||||
<div name="foo"></div>
|
||||
<div name='bar'></div>
|
||||
<div id="baz"></div>
|
||||
<div id=\'bam\'></div>
|
||||
[sitetree_link id="{$linkedPage->ID}"]
|
||||
<div id='bam'></div>
|
||||
<div id = "baz"></div>
|
||||
<div id = ""></div>
|
||||
<div id="some\'id"></div>
|
||||
<div id=bar></div>';
|
||||
<div id="some'id"></div>
|
||||
<div id=bar></div>
|
||||
EOS
|
||||
;
|
||||
$expected = array(
|
||||
'foo',
|
||||
'bar',
|
||||
|
Loading…
x
Reference in New Issue
Block a user