mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-21 07:50:37 +01:00
more secure isRelativeUrl (#8087)
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
cac4cba224
commit
acca0b956e
@@ -487,9 +487,18 @@
|
||||
});
|
||||
},
|
||||
|
||||
// https://github.com/sindresorhus/is-absolute-url
|
||||
isAbsoluteUrlRE: /^[a-zA-Z][a-zA-Z\d+\-.]*:/,
|
||||
isWinPathRE: /^[a-zA-Z]:\\/,
|
||||
isAbsoluteUrl: function (url) {
|
||||
if (utils.isWinPathRE.test(url)) {
|
||||
return false;
|
||||
}
|
||||
return utils.isAbsoluteUrlRE.test(url);
|
||||
},
|
||||
|
||||
isRelativeUrl: function (url) {
|
||||
var firstChar = String(url || '').charAt(0);
|
||||
return (firstChar === '.' || firstChar === '/');
|
||||
return !utils.isAbsoluteUrl(url);
|
||||
},
|
||||
|
||||
makeNumbersHumanReadable: function (elements) {
|
||||
|
||||
Reference in New Issue
Block a user