Skip to content

Commit

Permalink
Replaced all eval with array accessor, []. Improved on ready form URL…
Browse files Browse the repository at this point in the history
… path encoding
  • Loading branch information
SomajitDey committed Sep 20, 2024
1 parent 09f6e36 commit fb0b829
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1>Hello there! Feel free to post your message/comment/query to me</h1>
<iframe name="hidden_iframe" src="about:blank" hidden></iframe>

<script>
document.getElementById("submit").setAttribute("formaction", atob(location.pathname.substr(10,).replace(/_/g,'+').replace(/-/g,'/')));
document.getElementById("submit").setAttribute("formaction", atob(location.pathname.split('/').pop().replace(/_/g,'+').replace(/-/g,'/')));
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion app/bg-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function urlEncoded2Json(str){
for (let el of arr) {
let elArray = el.split('=');
let val = decodeURIComponent(elArray[1].replace( /\+/g, ' ' )).replace(/"/g,'\\"'); // Decoded and escaped
eval(`obj.${elArray[0]}="${val}"`);
obj[elArray[0]]=val;
}

return JSON.stringify(obj);
Expand Down
4 changes: 2 additions & 2 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function inbox(json){
const cell = document.createElement("td");

// Create a text entry:
entry = eval(`data.${keysEnumArray[key]}`);
entry = data[keysEnumArray[key]];

// Append entry to cell:
cell.append(entry);
Expand Down Expand Up @@ -140,7 +140,7 @@ function startWorker() {
document.getElementById("serverStatus").innerHTML = 'Live <span class="spinner-grow spinner-grow-sm"></span>';

document.getElementById("formActionURL").innerHTML = `<p class="alert alert-success">HTML Form Action URL: <u>${getFrom}</u></p>`;
document.getElementById("readyForm").href = `./${btoa(getFrom).replace(/\+/g,'_').replace(/\//g,'-')}`;
document.getElementById("readyForm").href = `./${btoa(getFrom).replace(/\+/g,'_').replace(/\//g,'-').replace(/=+$/,'')}`;
document.getElementById("testFormBtn").setAttribute("formaction", getFrom);
spaShow("testForm");
}
Expand Down

0 comments on commit fb0b829

Please sign in to comment.