@rowsncolumns/utils 9.2.35 → 9.2.36
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.
- package/dist/cjs/string.d.ts +10 -3
- package/dist/cjs/string.d.ts.map +1 -1
- package/dist/cjs/string.js +27 -8
- package/dist/esm/string.d.ts +10 -3
- package/dist/esm/string.d.ts.map +1 -1
- package/dist/esm/string.js +27 -8
- package/package.json +1 -1
package/dist/cjs/string.d.ts
CHANGED
|
@@ -64,9 +64,16 @@ export declare const supplant: (s: string, o: Record<string, any>) => string;
|
|
|
64
64
|
/**
|
|
65
65
|
* Normalize an external hyperlink target for the browser. A stored URL
|
|
66
66
|
* without a scheme ("paradigm.xyz") would otherwise be resolved relative to
|
|
67
|
-
* the current page. Prefixes https:// unless the URL already has a scheme
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* the current page. Prefixes https:// unless the URL already has a scheme,
|
|
68
|
+
* is protocol-relative ("//host"), or is a fragment/path reference.
|
|
69
|
+
*
|
|
70
|
+
* URLs with an explicit scheme are only passed through when the scheme is in
|
|
71
|
+
* the safe allowlist (http, https, mailto, tel, ftp — case-insensitive);
|
|
72
|
+
* anything else returns "" so it can never reach window.open/href sinks.
|
|
73
|
+
* Mirrors browser URL canonicalization before matching the scheme: embedded
|
|
74
|
+
* ASCII tab/newline characters are removed and leading/trailing C0 controls
|
|
75
|
+
* and whitespace are stripped, so obfuscations like "Java\tScript:" or a
|
|
76
|
+
* leading "\n" cannot smuggle a dangerous scheme past the check.
|
|
70
77
|
* @param url
|
|
71
78
|
* @returns
|
|
72
79
|
*/
|
package/dist/cjs/string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAK3E;;;;;;GAMG;AACH,eAAO,MA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,MAAM,oBAAoB,GAAI,KAAK,MAAM,WAoB/C,CAAC"}
|
package/dist/cjs/string.js
CHANGED
|
@@ -213,21 +213,40 @@ var supplant = function (s, o) {
|
|
|
213
213
|
};
|
|
214
214
|
exports.supplant = supplant;
|
|
215
215
|
// RFC 3986 scheme: ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ":"
|
|
216
|
-
var URL_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]
|
|
216
|
+
var URL_SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;
|
|
217
|
+
// Schemes an external hyperlink is allowed to carry. Anything else with an
|
|
218
|
+
// explicit scheme (javascript:, data:, vbscript:, …) is a script/content
|
|
219
|
+
// injection vector and is rejected.
|
|
220
|
+
var SAFE_URL_SCHEMES = new Set(["http", "https", "mailto", "tel", "ftp"]);
|
|
217
221
|
/**
|
|
218
222
|
* Normalize an external hyperlink target for the browser. A stored URL
|
|
219
223
|
* without a scheme ("paradigm.xyz") would otherwise be resolved relative to
|
|
220
|
-
* the current page. Prefixes https:// unless the URL already has a scheme
|
|
221
|
-
*
|
|
222
|
-
*
|
|
224
|
+
* the current page. Prefixes https:// unless the URL already has a scheme,
|
|
225
|
+
* is protocol-relative ("//host"), or is a fragment/path reference.
|
|
226
|
+
*
|
|
227
|
+
* URLs with an explicit scheme are only passed through when the scheme is in
|
|
228
|
+
* the safe allowlist (http, https, mailto, tel, ftp — case-insensitive);
|
|
229
|
+
* anything else returns "" so it can never reach window.open/href sinks.
|
|
230
|
+
* Mirrors browser URL canonicalization before matching the scheme: embedded
|
|
231
|
+
* ASCII tab/newline characters are removed and leading/trailing C0 controls
|
|
232
|
+
* and whitespace are stripped, so obfuscations like "Java\tScript:" or a
|
|
233
|
+
* leading "\n" cannot smuggle a dangerous scheme past the check.
|
|
223
234
|
* @param url
|
|
224
235
|
* @returns
|
|
225
236
|
*/
|
|
226
237
|
var normalizeExternalUrl = function (url) {
|
|
227
|
-
var trimmed = url
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
var trimmed = url
|
|
239
|
+
.replace(/[\t\n\r]/g, "")
|
|
240
|
+
.replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, "")
|
|
241
|
+
.trim();
|
|
242
|
+
if (!trimmed) {
|
|
243
|
+
return "";
|
|
244
|
+
}
|
|
245
|
+
var schemeMatch = URL_SCHEME.exec(trimmed);
|
|
246
|
+
if (schemeMatch) {
|
|
247
|
+
return SAFE_URL_SCHEMES.has(schemeMatch[1].toLowerCase()) ? trimmed : "";
|
|
248
|
+
}
|
|
249
|
+
if (trimmed.startsWith("//") ||
|
|
231
250
|
trimmed.startsWith("#") ||
|
|
232
251
|
trimmed.startsWith("/")) {
|
|
233
252
|
return trimmed;
|
package/dist/esm/string.d.ts
CHANGED
|
@@ -64,9 +64,16 @@ export declare const supplant: (s: string, o: Record<string, any>) => string;
|
|
|
64
64
|
/**
|
|
65
65
|
* Normalize an external hyperlink target for the browser. A stored URL
|
|
66
66
|
* without a scheme ("paradigm.xyz") would otherwise be resolved relative to
|
|
67
|
-
* the current page. Prefixes https:// unless the URL already has a scheme
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* the current page. Prefixes https:// unless the URL already has a scheme,
|
|
68
|
+
* is protocol-relative ("//host"), or is a fragment/path reference.
|
|
69
|
+
*
|
|
70
|
+
* URLs with an explicit scheme are only passed through when the scheme is in
|
|
71
|
+
* the safe allowlist (http, https, mailto, tel, ftp — case-insensitive);
|
|
72
|
+
* anything else returns "" so it can never reach window.open/href sinks.
|
|
73
|
+
* Mirrors browser URL canonicalization before matching the scheme: embedded
|
|
74
|
+
* ASCII tab/newline characters are removed and leading/trailing C0 controls
|
|
75
|
+
* and whitespace are stripped, so obfuscations like "Java\tScript:" or a
|
|
76
|
+
* leading "\n" cannot smuggle a dangerous scheme past the check.
|
|
70
77
|
* @param url
|
|
71
78
|
* @returns
|
|
72
79
|
*/
|
package/dist/esm/string.d.ts.map
CH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AAa,EACpB,MAAK,aAAa,GAAG,IAAY,KAChC,SAQF,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,WAKzD,CAAC;AAUF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,WAoB/C,CAAC"}
|
package/dist/esm/string.js
CHANGED
|
@@ -190,21 +190,40 @@ export const supplant = (s, o) => {
|
|
|
190
190
|
});
|
|
191
191
|
};
|
|
192
192
|
// RFC 3986 scheme: ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ":"
|
|
193
|
-
const URL_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]
|
|
193
|
+
const URL_SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;
|
|
194
|
+
// Schemes an external hyperlink is allowed to carry. Anything else with an
|
|
195
|
+
// explicit scheme (javascript:, data:, vbscript:, …) is a script/content
|
|
196
|
+
// injection vector and is rejected.
|
|
197
|
+
const SAFE_URL_SCHEMES = new Set(["http", "https", "mailto", "tel", "ftp"]);
|
|
194
198
|
/**
|
|
195
199
|
* Normalize an external hyperlink target for the browser. A stored URL
|
|
196
200
|
* without a scheme ("paradigm.xyz") would otherwise be resolved relative to
|
|
197
|
-
* the current page. Prefixes https:// unless the URL already has a scheme
|
|
198
|
-
*
|
|
199
|
-
*
|
|
201
|
+
* the current page. Prefixes https:// unless the URL already has a scheme,
|
|
202
|
+
* is protocol-relative ("//host"), or is a fragment/path reference.
|
|
203
|
+
*
|
|
204
|
+
* URLs with an explicit scheme are only passed through when the scheme is in
|
|
205
|
+
* the safe allowlist (http, https, mailto, tel, ftp — case-insensitive);
|
|
206
|
+
* anything else returns "" so it can never reach window.open/href sinks.
|
|
207
|
+
* Mirrors browser URL canonicalization before matching the scheme: embedded
|
|
208
|
+
* ASCII tab/newline characters are removed and leading/trailing C0 controls
|
|
209
|
+
* and whitespace are stripped, so obfuscations like "Java\tScript:" or a
|
|
210
|
+
* leading "\n" cannot smuggle a dangerous scheme past the check.
|
|
200
211
|
* @param url
|
|
201
212
|
* @returns
|
|
202
213
|
*/
|
|
203
214
|
export const normalizeExternalUrl = (url) => {
|
|
204
|
-
const trimmed = url
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
215
|
+
const trimmed = url
|
|
216
|
+
.replace(/[\t\n\r]/g, "")
|
|
217
|
+
.replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, "")
|
|
218
|
+
.trim();
|
|
219
|
+
if (!trimmed) {
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
const schemeMatch = URL_SCHEME.exec(trimmed);
|
|
223
|
+
if (schemeMatch) {
|
|
224
|
+
return SAFE_URL_SCHEMES.has(schemeMatch[1].toLowerCase()) ? trimmed : "";
|
|
225
|
+
}
|
|
226
|
+
if (trimmed.startsWith("//") ||
|
|
208
227
|
trimmed.startsWith("#") ||
|
|
209
228
|
trimmed.startsWith("/")) {
|
|
210
229
|
return trimmed;
|