mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4733 from feejin/htmleditorfield-anchor-improvements
Check for id attributes for anchor targets and prevent partial matches
This commit is contained in:
commit
234e5a8a59
@ -519,7 +519,7 @@ 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("/name=\"([^\"]+?)\"|name='([^']+?)'/im", $page->Content, $matches)) {
|
if (preg_match_all("/\s(name|id)=\"([^\"]+?)\"|\s(name|id)='([^']+?)'/im", $page->Content, $matches)) {
|
||||||
$anchors = $matches[1];
|
$anchors = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,10 +716,11 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
|
|||||||
// http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#h-12.2
|
// http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#h-12.2
|
||||||
|
|
||||||
if(ed) {
|
if(ed) {
|
||||||
var raw = ed.getContent().match(/name="([^"]+?)"|name='([^']+?)'/gim);
|
var raw = ed.getContent().match(/\s(name|id)="([^"]+?)"|\s(name|id)='([^']+?)'/gim);
|
||||||
if (raw && raw.length) {
|
if (raw && raw.length) {
|
||||||
for(var i = 0; i < raw.length; i++) {
|
for(var i = 0; i < raw.length; i++) {
|
||||||
collectedAnchors.push(raw[i].substr(6).replace(/"$/, ''));
|
var indexStart = (raw[i].indexOf('id=') == -1) ? 7 : 5;
|
||||||
|
collectedAnchors.push(raw[i].substr(indexStart).replace(/"$/, ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user