From 82c0385fe5d523ebee308e006e5f286ca432ac91 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 17 Dec 2019 16:04:47 +0100 Subject: [PATCH 1/2] MOBILE-3213 core: Handle anchors when cleaning extensions --- src/providers/utils/mimetype.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/providers/utils/mimetype.ts b/src/providers/utils/mimetype.ts index 19c54139c..c162f3dc7 100644 --- a/src/providers/utils/mimetype.ts +++ b/src/providers/utils/mimetype.ts @@ -68,7 +68,13 @@ export class CoreMimetypeUtilsProvider { } // If the extension has parameters, remove them. - const position = extension.indexOf('?'); + let position = extension.indexOf('?'); + if (position > -1) { + extension = extension.substr(0, position); + } + + // If the extension has an anchor, remove it. + position = extension.indexOf('#'); if (position > -1) { extension = extension.substr(0, position); } From 4601df6fc4385bb6c68eda7f56142d4b533171ae Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 18 Dec 2019 10:50:10 +0100 Subject: [PATCH 2/2] MOBILE-3213 data: Fix latlong geo links --- .../data/fields/latlong/component/latlong.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/addon/mod/data/fields/latlong/component/latlong.ts b/src/addon/mod/data/fields/latlong/component/latlong.ts index 869f19c63..912f628d3 100644 --- a/src/addon/mod/data/fields/latlong/component/latlong.ts +++ b/src/addon/mod/data/fields/latlong/component/latlong.ts @@ -13,6 +13,7 @@ // limitations under the License. import { Component } from '@angular/core'; import { FormBuilder } from '@angular/forms'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { Platform } from 'ionic-angular'; import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; @@ -30,8 +31,11 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo north: number; east: number; - constructor(protected fb: FormBuilder, private platform: Platform, private geolocation: Geolocation, - private domUtils: CoreDomUtilsProvider) { + constructor(protected fb: FormBuilder, + protected platform: Platform, + protected geolocation: Geolocation, + protected domUtils: CoreDomUtilsProvider, + protected sanitizer: DomSanitizer) { super(fb); } @@ -58,16 +62,19 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo * @param east Degrees East. * @return Link to maps depending on platform. */ - getLatLongLink(north: number, east: number): string { + getLatLongLink(north: number, east: number): SafeUrl { if (north !== null || east !== null) { - const northFixed = north ? north.toFixed(4) : '0.0000', - eastFixed = east ? east.toFixed(4) : '0.0000'; + const northFixed = north ? north.toFixed(4) : '0.0000'; + const eastFixed = east ? east.toFixed(4) : '0.0000'; + let url; if (this.platform.is('ios')) { - return 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed; + url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed; + } else { + url = 'geo:' + northFixed + ',' + eastFixed; } - return 'geo:' + northFixed + ',' + eastFixed; + return this.sanitizer.bypassSecurityTrustUrl(url); } }