MOBILE-3163 core: Check site URL when treating pluginfile URLs
parent
eb19e61a2d
commit
7471f54f9c
|
@ -1404,8 +1404,8 @@ export class CoreSite {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const siteUrl = this.textUtils.removeEndingSlash(this.urlUtils.removeProtocolAndWWW(this.siteUrl));
|
const siteUrl = this.textUtils.addEndingSlash(this.urlUtils.removeProtocolAndWWW(this.siteUrl));
|
||||||
url = this.urlUtils.removeProtocolAndWWW(url);
|
url = this.textUtils.addEndingSlash(this.urlUtils.removeProtocolAndWWW(url));
|
||||||
|
|
||||||
return url.indexOf(siteUrl) == 0;
|
return url.indexOf(siteUrl) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,24 @@ export class CoreTextUtilsProvider {
|
||||||
constructor(private translate: TranslateService, private langProvider: CoreLangProvider, private modalCtrl: ModalController,
|
constructor(private translate: TranslateService, private langProvider: CoreLangProvider, private modalCtrl: ModalController,
|
||||||
private sanitizer: DomSanitizer, private platform: Platform) { }
|
private sanitizer: DomSanitizer, private platform: Platform) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add ending slash from a path or URL.
|
||||||
|
*
|
||||||
|
* @param {string} text Text to treat.
|
||||||
|
* @return {string} Treated text.
|
||||||
|
*/
|
||||||
|
addEndingSlash(text: string): string {
|
||||||
|
if (!text) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text.slice(-1) != '/') {
|
||||||
|
return text + '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an address as a string, return a URL to open the address in maps.
|
* Given an address as a string, return a URL to open the address in maps.
|
||||||
*
|
*
|
||||||
|
|
|
@ -121,8 +121,8 @@ export class CoreUrlUtilsProvider {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if is a valid URL (contains the pluginfile endpoint).
|
// Check if is a valid URL (contains the pluginfile endpoint) and belongs to the site.
|
||||||
if (!this.isPluginFileUrl(url)) {
|
if (!this.isPluginFileUrl(url) || url.indexOf(this.textUtils.addEndingSlash(siteUrl)) !== 0) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue