You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop,Mobile: Allow internal links to target elements using the name attribute (#11671)
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
<img src="test/" class="jop-noMdConv"/>
|
<img src="test/" id="getElementById" class="jop-noMdConv"/>
|
||||||
<img src="http://example.com/test.png" class="jop-noMdConv"/>
|
<img src="http://example.com/test.png" id="getElementById" class="jop-noMdConv"/>
|
||||||
|
<img id="test2" src="http://example.com/test.png" class="jop-noMdConv"/>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
<img name=getElementById src=test/>
|
<img name=getElementById src=test/>
|
||||||
|
|
||||||
<IMG NAME="getElementById" SRC="http://example.com/test.png">
|
<IMG NAME="getElementById" SRC="http://example.com/test.png">
|
||||||
|
|
||||||
|
<IMG NAME="test" ID="test2" SRC="http://example.com/test.png">
|
||||||
|
|||||||
@@ -285,6 +285,20 @@ class HtmlUtils {
|
|||||||
|
|
||||||
attrs = { ...attrs };
|
attrs = { ...attrs };
|
||||||
|
|
||||||
|
// Allowing the 'name' attribute allows an attacker to overwrite
|
||||||
|
// DOM methods (e.g. getElementById) with elements.
|
||||||
|
if ('name' in attrs) {
|
||||||
|
const oldName = attrs['name'];
|
||||||
|
delete attrs['name'];
|
||||||
|
|
||||||
|
// For compatibility reasons, support rewriting name= as id=.
|
||||||
|
// This allows internal links specified with name="target" to continue
|
||||||
|
// to work.
|
||||||
|
if (!('id' in attrs)) {
|
||||||
|
attrs['id'] = oldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove all the attributes that start with "on", which
|
// Remove all the attributes that start with "on", which
|
||||||
// normally should be JavaScript events. A better solution
|
// normally should be JavaScript events. A better solution
|
||||||
// would be to blacklist known events only but it seems the
|
// would be to blacklist known events only but it seems the
|
||||||
@@ -308,12 +322,6 @@ class HtmlUtils {
|
|||||||
attrs['href'] = '#';
|
attrs['href'] = '#';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allowing the 'name' attribute allows an attacker to overwrite
|
|
||||||
// DOM methods (e.g. getElementById) with elements.
|
|
||||||
if ('name' in attrs) {
|
|
||||||
delete attrs['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to clear any such attribute, otherwise it will
|
// We need to clear any such attribute, otherwise it will
|
||||||
// make any arbitrary link open within the application.
|
// make any arbitrary link open within the application.
|
||||||
if ('data-from-md' in attrs) {
|
if ('data-from-md' in attrs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user