workaround for malforrmed url

This commit is contained in:
AJ ONeal 2018-02-26 12:02:44 -07:00
parent c9affeac58
commit a3f3c4b041
3 changed files with 12 additions and 21 deletions

View File

@ -1,18 +1,3 @@
<!-- BANNER_TPL_BEGIN -->
About Daplie: We're taking back the Internet!
--------------
Down with Google, Apple, and Facebook!
We're re-decentralizing the web and making it read-write again - one home cloud system at a time.
Tired of serving the Empire? Come join the Rebel Alliance:
<a href="mailto:jobs@daplie.com">jobs@daplie.com</a> | [Invest in Daplie on Wefunder](https://daplie.com/invest/) | [Pre-order Cloud](https://daplie.com/preorder/), The World's First Home Server for Everyone
<!-- BANNER_TPL_END -->
# redirect-https
Redirect from HTTP to HTTPS using meta redirects

View File

@ -35,8 +35,14 @@ module.exports = function (opts) {
;
//var encodedLocation = encodeURI(newLocation);
var escapedLocation = escapeHtml(newLocation);
var encodedLocation;
try {
encodedLocation = decodeURIComponent(newLocation);
} catch(e) {
encodedLocation = "#/error/?error_message=" + e.toString();
}
var body = opts.body
.replace(/{{\s*HTML_URL\s*}}/ig, escapeHtml(decodeURIComponent(newLocation)))
.replace(/{{\s*HTML_URL\s*}}/ig, escapeHtml(encodedLocation))
.replace(/{{\s*URL\s*}}/ig, escapedLocation)
.replace(/{{\s*UNSAFE_URL\s*}}/ig, newLocation)
;

View File

@ -1,6 +1,6 @@
{
"name": "redirect-https",
"version": "1.1.1",
"version": "1.1.2",
"description": "Redirect from HTTP to HTTPS using meta redirects",
"main": "index.js",
"scripts": {
@ -8,7 +8,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/Daplie/node-redirect-https.git"
"url": "git+https://git.coolaj86.com/coolaj86/redirect-https.js.git"
},
"keywords": [
"https",
@ -22,10 +22,10 @@
"author": "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.com/)",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/Daplie/node-redirect-https/issues"
"url": "https://git.coolaj86.com/coolaj86/redirect-https.js/issues"
},
"homepage": "https://github.com/Daplie/node-redirect-https#readme",
"homepage": "https://git.coolaj86.com/coolaj86/redirect-https.js#readme",
"dependencies": {
"escape-html": "^1.0.2"
"escape-html": "^1.0.3"
}
}