mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-14 19:35:38 +00:00
Fix exceptions on weirdly encoded URLs
`decodeURI( fragment )` can throw if the fragment isn't correctly encoded – e.g. when it's just '#%'. Use mw.util.percentDecodeFragment() instead, which uses a more resilient algorithm. Change-Id: I8447771ad2ae33da52b71d4127981dd8a2018a7d
This commit is contained in:
parent
9f650c92ee
commit
1bb3b597ec
|
@ -592,14 +592,14 @@ function init( $container, state ) {
|
|||
return !pattern.test( fragment );
|
||||
} ) ) {
|
||||
findCommentQuery = {
|
||||
heading: decodeURI( fragment ).replace( / /g, '_' ),
|
||||
heading: mw.util.percentDecodeFragment( fragment ).replace( / /g, '_' ),
|
||||
page: mw.config.get( 'wgRelevantPageName' )
|
||||
};
|
||||
isHeading = true;
|
||||
}
|
||||
} else if ( highlightResult.highlighted.length === 0 && highlightResult.requested.length === 1 ) {
|
||||
findCommentQuery = {
|
||||
idorname: decodeURI( highlightResult.requested[ 0 ] )
|
||||
idorname: mw.util.percentDecodeFragment( highlightResult.requested[ 0 ] )
|
||||
};
|
||||
isHeading = highlightResult.requested[ 0 ].slice( 0, 1 ) === 'h';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue