Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Adding "preserve" to attributeCheckMethods #507

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions parser_rules/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ var wysihtml5ParserRules = {
* - src: allows something like "/foobar.jpg", "http://google.com", ...
* - href: allows something like "mailto:[email protected]", "http://google.com", "/foobar.jpg"
* - alt: strips unwanted characters. if the attribute is not set, then it gets set (to ensure valid and compatible HTML)
* - numbers: ensures that the attribute only contains numeric characters
* - numbers: ensures that the attribute only contains numeric characters
* - preserve: keep the current value in the property.
*/
"tags": {
"tr": {
Expand Down Expand Up @@ -180,11 +181,11 @@ var wysihtml5ParserRules = {
},
"a": {
"check_attributes": {
"target": "preserve", // If a user specifies a target, we should keep it that way.
"href": "url" // if you compiled master manually then change this from 'url' to 'href'
},
"set_attributes": {
"rel": "nofollow",
"target": "_blank"
}
},
"img": {
Expand Down
2 changes: 1 addition & 1 deletion parser_rules/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ var wysihtml5ParserRules = {
li: {},
a: {
set_attributes: {
target: "_blank",
rel: "nofollow"
},
check_attributes: {
target: "preserve", // If a user specifies a target, we should keep it that way.
href: "url" // important to avoid XSS
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/dom/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ wysihtml5.dom.parse = (function() {
attributeValue = (attributeValue || "").replace(REG_EXP, "");
return attributeValue || null;
};
})(),

preserve: (function() {
return function(attributeValue) {
return attributeValue;
};
})()
};

Expand Down