mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-04 20:57:56 +02:00
fix: fix relative to abs url
This commit is contained in:
@@ -8,6 +8,7 @@ function urlRel2abs(url) {
|
|||||||
return url; //Url is already absolute
|
return url; //Url is already absolute
|
||||||
}
|
}
|
||||||
var base_url = location.href.match(/^(.+)\/?(?:#.+)?$/)[0] + "/";
|
var base_url = location.href.match(/^(.+)\/?(?:#.+)?$/)[0] + "/";
|
||||||
|
|
||||||
if (url.substring(0, 2) == "//") return location.protocol + url;
|
if (url.substring(0, 2) == "//") return location.protocol + url;
|
||||||
else if (url.charAt(0) == "/")
|
else if (url.charAt(0) == "/")
|
||||||
return location.protocol + "//" + location.host + url;
|
return location.protocol + "//" + location.host + url;
|
||||||
@@ -17,17 +18,17 @@ function urlRel2abs(url) {
|
|||||||
else url = "../" + url;
|
else url = "../" + url;
|
||||||
|
|
||||||
url = base_url + url;
|
url = base_url + url;
|
||||||
var i = 0;
|
|
||||||
while (/\/\.\.\//.test((url = url.replace(/[^\/]+\/+\.\.\//g, ""))));
|
|
||||||
|
|
||||||
|
while (/\/\.\.\//.test((url = url.replace(/[^\/]+\/+\.\.\//g, ""))));
|
||||||
/* Escape certain characters to prevent XSS */
|
/* Escape certain characters to prevent XSS */
|
||||||
url = url
|
url = url
|
||||||
.replace(/\.$/, "")
|
.replace(/\.$/, "")
|
||||||
.replace(/\/\./g, "")
|
.replace(/\/\.\//g, "")
|
||||||
.replace(/"/g, "%22")
|
.replace(/"/g, "%22")
|
||||||
.replace(/'/g, "%27")
|
.replace(/'/g, "%27")
|
||||||
.replace(/</g, "%3C")
|
.replace(/</g, "%3C")
|
||||||
.replace(/>/g, "%3E");
|
.replace(/>/g, "%3E");
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user