@fundamental-ngx/cdk 0.65.1-rc.0 → 0.65.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7039,14 +7039,41 @@ class SafePipe {
|
|
|
7039
7039
|
return this.sanitizer.bypassSecurityTrustStyle(value);
|
|
7040
7040
|
case 'script':
|
|
7041
7041
|
return this.sanitizer.bypassSecurityTrustScript(value);
|
|
7042
|
-
case 'url':
|
|
7042
|
+
case 'url': {
|
|
7043
|
+
if (!this._isSafeUrl(value)) {
|
|
7044
|
+
return this.sanitizer.bypassSecurityTrustUrl('');
|
|
7045
|
+
}
|
|
7043
7046
|
return this.sanitizer.bypassSecurityTrustUrl(value);
|
|
7047
|
+
}
|
|
7044
7048
|
case 'resourceUrl':
|
|
7045
7049
|
return this.sanitizer.bypassSecurityTrustResourceUrl(value);
|
|
7046
7050
|
default:
|
|
7047
7051
|
throw new Error(`Invalid safe type specified: ${type}`);
|
|
7048
7052
|
}
|
|
7049
7053
|
}
|
|
7054
|
+
/**
|
|
7055
|
+
* @hidden
|
|
7056
|
+
*
|
|
7057
|
+
* Browsers strip ASCII tab/newline characters from the whole URL before parsing, so a
|
|
7058
|
+
* value like `java\tscript:...` must not evade scheme detection. Any URL containing C0
|
|
7059
|
+
* control characters is rejected outright — legitimate URLs never contain them.
|
|
7060
|
+
*/
|
|
7061
|
+
_isSafeUrl(value) {
|
|
7062
|
+
if (value == null) {
|
|
7063
|
+
return false;
|
|
7064
|
+
}
|
|
7065
|
+
const str = String(value).trim();
|
|
7066
|
+
if (str === '') {
|
|
7067
|
+
return true;
|
|
7068
|
+
}
|
|
7069
|
+
if (Array.from(str).some((ch) => ch.charCodeAt(0) < 32 || ch.charCodeAt(0) === 127)) {
|
|
7070
|
+
return false;
|
|
7071
|
+
}
|
|
7072
|
+
if (!/^[a-z][a-z0-9+.-]*:/i.test(str)) {
|
|
7073
|
+
return true;
|
|
7074
|
+
}
|
|
7075
|
+
return /^(https?|mailto|tel):/i.test(str);
|
|
7076
|
+
}
|
|
7050
7077
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: SafePipe, deps: [{ token: i1$4.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
7051
7078
|
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.2.1", ngImport: i0, type: SafePipe, isStandalone: true, name: "safe" }); }
|
|
7052
7079
|
}
|