Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/50267
Change subject: Clone tokens in Sanitizer:onAnchor before updating them.
......................................................................
Clone tokens in Sanitizer:onAnchor before updating them.
* Since original tokens are frozen, and not all of them are
always cloned (used to be cloned always in AttrExpander till
that changed in 46119efb), clone them in onAnchor if they
are going to be modified -- do we need a 'isFrozen' flag on
tokens which we can test to avoid cloning unnecessarily?
* Fixes: node roundtrip-test.js 'Wikipedia:Importance/Archive 01'
which used to crash with an attempt to set a read only attr.
of the token being sanitized.
* No change in parserTest results.
Change-Id: Ia29756acb15f9762e399c57efb7687b12fec1c96
---
M js/lib/ext.core.Sanitizer.js
1 file changed, 5 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/67/50267/1
diff --git a/js/lib/ext.core.Sanitizer.js b/js/lib/ext.core.Sanitizer.js
index 2b62c73..540fdec 100644
--- a/js/lib/ext.core.Sanitizer.js
+++ b/js/lib/ext.core.Sanitizer.js
@@ -622,11 +622,13 @@
if ( hrefKV !== null ) {
var origHref = Util.tokensToString( hrefKV.v ),
newHref = this.sanitizeHref( origHref );
- if ( newHref !== null ) {
- hrefKV.v = newHref;
- } else {
+ if ( newHref === null ) {
+ token = token.clone();
token.removeAttribute( 'href' );
token.setShadowInfo('href', newHref, origHref);
+ } else if (newHref !== origHref) {
+ token = token.clone();
+ hrefKV.v = newHref;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/50267
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia29756acb15f9762e399c57efb7687b12fec1c96
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits