I've got a single dependency on jQuery that I don't want, and need a browser-safe method to decode server-side html encoded content.
The effect I'm going for is to replace an existing DOM element with the the html that gets decoded, along the following lines:
value contains an html-encoded string.
Alternatively, an more direct approach would also be welcome.
I would like to see HTML in the Kendo UI Editor like
How can i do these?
I'm trying to protect myself from sql injection and am using:
When posting HTML it looks something like this:
<span class="\"className\""><p class="\"pClass\"" id="\"pId\""></p></span>
I'm not sure how many other variations real_escape_string adds so don't want to just replace a few and miss others... How do I "decode" this back into correctly formatted HTML, with something like:
What should be done against contents of href attribute: HTML or URL encoding?
<a href="???">link text</a>
On the one hand, since href attribute contains URL I should use URL encoding. On the other hand, I'm inserting this URL into HTML, so it must be HTML encoded.
Please help me to overcome this contradiction.
Here's the contradiction. Suppose there might be the '<' and '>' characters in the URL. URL encoding won't escape them, so there will be reserved HTML characters inside the href attribute, which violates the standard. HTML encoding will escape '<' and '>' characters and HTML will be valid, but after that there will be unexpected '&' characters in the URL (this is reserved character for URL, it's used as a delimiter of query string parameters).
I was wrong about '<' and '>' characters, they are actually percent escaped by URL encoding. If so, URL encoding is sufficient in this case, isn't it?
I need to convert the Emojis (e.g.
😀) in strings to their respective HTML code entities (e.g.
😀) on a PHP 5.3 site.
I need to do this so that user input gets properly stored in a legacy script MySQL Database to later display properly when shown back to the user. When attempting to save Emojis directly from user input, they are incorrectly saved as
? in its Database. This legacy script does not support
utf8mb4 in MySQL (this solution failed) and all attempts at converting its Database, Tables, and Columns to
utf8mb4 have not solved this problem, so the only solution I have left which I already confirmed works is converting user-inputted Emojis in strings to their respective HTML code entities to correctly store those entities as-is in the Database so that they display correctly as Emojis when retrieved since modern browsers automatically convert those Emoji entities to Emoji characters.
I have also tried this solution, but it does not work in PHP 5.3, only in 5.4 and above. (I cannot upgrade to 5.4 on this particular site because the legacy script it depends on only works in 5.3 and cannot be changed or upgraded under any circumstances.)
I have also tried this solution, which works in PHP 5.3, but you can't feed it a string, only the specific Emoji, so it does not solve my problem despite working in PHP 5.3.
I only need the Emojis in a string converted, nothing else. (However, if that is not possible, then I suppose I can live with other HTML entities being converted with it, like
&, but I prefer that not be the case.)
So how can I convert Emojis in strings to their respective HTML code entities in PHP 5.3 such that a string like
this & that 😎 gets converted to
this & that 😎?