Question

I have a textarea from I got the value like this $(ctrl).val() then I receive this %3ch1%3eMy System%3c/h1%3e so I've been trying to encode this value into this:

<h1>My System</h1>

But I don't know how.

I found on internet many examples like this

jQuery('<div />').html('Some text with &lt;div&gt;html&lt;/div&gt;').text()

But no success! The decode text is different.

Was it helpful?

Solution

It's inherently unsafe/insecure to randomly unescape HTML content unless you know where its coming from (fully).

In any case:

unescape('%3ch1%3eMy System%3c/h1%3e') = "<h1>My System</h1>"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top