I have some Ajaxing going on and I have 2 blocks of source code. The first is:
window.lastSavedContents = "<?php echo htmlentities( $contents ); ?>";
The second is whatever the user types into a text editor. The problem is window.lastSavedContents is htmlentities encoded, whereas the second block is not.
How can I check for equivalence?
First, don’t use
htmlentities, buthtmlspecialchars, that only encodes<,>,&and". That way, you can simply replace those entities usingIf you still want to use
htmlentitiesyou can simply create a temporarydiv: