Extended Brain Storage

JavaScript: unescape and decodeURIComponent Functions

Posted on October 6, 2015

A simple usage of the unescape and decodeURIComponent() "obfuscation" functions in JavaScript...

Disclaimer

Surely, it could have been written in a optimized and shortened way. The intention was to be easy to read and more obvious.

Note: The unescape() function was deprecated in JavaScript version 1.5. The decodeURIComponent() should be used instead.


Source Code

JavaScript code:

function unescp(){
document.getElementById('unescres').value = decodeURIComponent(document.getElementById('unescin').value);
}

function escp(){
document.getElementById('escres').value = encodeURIComponent(document.getElementById('escin').value);
}

HTML code:

Escaped input:<input type="text" id="unescin" oninput="unescp();" />
Unescaped result:<input type="text" id="unescres" />

Unescaped input:<input type="text" id="escin" oninput="escp();" />
Escaped result:<input type="text" id="escres" />

Tags: #JavaScript #unescape #obfuscation #security

⏴ Previous Post Next Post ⏵