mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Use ve.safeDecodeURIComponent()"
This commit is contained in:
commit
b8f9e43187
|
@ -172,7 +172,7 @@ ve.ce.MWTransclusionNode.prototype.getRenderedDomElements = function ( domElemen
|
|||
var targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref(
|
||||
this.href, transclusionNode.getModelHtmlDocument()
|
||||
),
|
||||
normalisedHref = decodeURIComponent( targetData.title );
|
||||
normalisedHref = ve.safeDecodeURIComponent( targetData.title );
|
||||
if ( mw.Title.newFromText( normalisedHref ) ) {
|
||||
normalisedHref = mw.Title.newFromText( normalisedHref ).getPrefixedText();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ ve.dm.MWInternalLinkAnnotation.static.toDataElement = function ( domElements, co
|
|||
type: this.name,
|
||||
attributes: {
|
||||
hrefPrefix: targetData.hrefPrefix,
|
||||
title: decodeURIComponent( targetData.title ).replace( /_/g, ' ' ),
|
||||
title: ve.safeDecodeURIComponent( targetData.title ).replace( /_/g, ' ' ),
|
||||
normalizedTitle: this.normalizeTitle( targetData.title ),
|
||||
lookupTitle: this.getLookupTitle( targetData.title ),
|
||||
origTitle: targetData.title
|
||||
|
@ -92,7 +92,7 @@ ve.dm.MWInternalLinkAnnotation.static.getHref = function ( dataElement ) {
|
|||
var href,
|
||||
title = dataElement.attributes.title,
|
||||
origTitle = dataElement.attributes.origTitle;
|
||||
if ( origTitle !== undefined && decodeURIComponent( origTitle ).replace( /_/g, ' ' ) === title ) {
|
||||
if ( origTitle !== undefined && ve.safeDecodeURIComponent( origTitle ).replace( /_/g, ' ' ) === title ) {
|
||||
// Restore href from origTitle
|
||||
href = origTitle;
|
||||
// Only use hrefPrefix if restoring from origTitle
|
||||
|
|
|
@ -41,9 +41,9 @@ ve.dm.MWCategoryMetaItem.static.toDataElement = function ( domElements ) {
|
|||
type: this.name,
|
||||
attributes: {
|
||||
hrefPrefix: matches[1],
|
||||
category: decodeURIComponent( matches[2] ).replace( /_/g, ' ' ),
|
||||
category: ve.safeDecodeURIComponent( matches[2] ).replace( /_/g, ' ' ),
|
||||
origCategory: matches[2],
|
||||
sortkey: decodeURIComponent( rawSortkey ).replace( /_/g, ' ' ),
|
||||
sortkey: ve.safeDecodeURIComponent( rawSortkey ).replace( /_/g, ' ' ),
|
||||
origSortkey: rawSortkey
|
||||
}
|
||||
};
|
||||
|
@ -57,8 +57,8 @@ ve.dm.MWCategoryMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
|||
sortkey = dataElement.attributes.sortkey || '',
|
||||
origCategory = dataElement.attributes.origCategory || '',
|
||||
origSortkey = dataElement.attributes.origSortkey || '',
|
||||
normalizedOrigCategory = decodeURIComponent( origCategory ).replace( /_/g, ' ' ),
|
||||
normalizedOrigSortkey = decodeURIComponent( origSortkey ).replace( /_/g, ' ' );
|
||||
normalizedOrigCategory = ve.safeDecodeURIComponent( origCategory ).replace( /_/g, ' ' ),
|
||||
normalizedOrigSortkey = ve.safeDecodeURIComponent( origSortkey ).replace( /_/g, ' ' );
|
||||
if ( normalizedOrigSortkey === sortkey ) {
|
||||
sortkey = origSortkey;
|
||||
} else {
|
||||
|
|
|
@ -206,13 +206,7 @@ ve.dm.MWImageNode.prototype.getFilename = function () {
|
|||
var resource = this.getAttribute( 'resource' ) || '',
|
||||
filename = resource.replace( /^(\.+\/)*/, '' );
|
||||
|
||||
// Protect against decodeURIComponent() throwing exceptions
|
||||
try {
|
||||
filename = decodeURIComponent( filename );
|
||||
} catch ( e ) {
|
||||
ve.log( 'URI decoding exception', e );
|
||||
}
|
||||
return filename;
|
||||
return ve.safeDecodeURIComponent( filename );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue