sambowler / entitifier

Convert characters in HTML/text to the correct HTML entities.
http://entitifier.sambowler.com
25 stars 1 forks source link

Fixed <% … %> and <?php … ?> #4

Closed hawx closed 13 years ago

hawx commented 14 years ago

I have moved the entities out into hashes so there is a little less repetition. Also I have got <?php … ?> and <% … %> tags to be ignored, but only in text mode. I tried in html mode but it will probably take a completely different approach because it would just crash.

sambowler commented 14 years ago

Awesome, I knew there was a better way of doing the entities. Thanks!

sambowler commented 14 years ago

After having a more in-depth look, your changes to the way entities are processed reintroduces an issue where submitting "&" spits out "&amp;". Line 15 in entitifier.rb previously just replaced "&amp;" with "&" but that no longer seems to work, any ideas on a (better) workaround for this?

I really appreciate your contribution, thanks again.

hawx commented 14 years ago

I don't really understand what you mean. When I put in "&" it should turn into "&" or what?

sambowler commented 14 years ago

If a user were to have already converted an ampersand i.e it literally says "& amp;" then it will still convert the ampersand as if it were normal text so the result is "& amp;amp;".

hawx commented 14 years ago

I'm not seeing this bug, for me it works the same as before.

sambowler commented 14 years ago

That was meant to be "& amp;" and "& amp;amp;" but obviously without the spaces.

hawx commented 14 years ago

I understand what you mean now but I still don't get the problem, try adding these two lines at the bottom of entitifier.rb

p textReplace("&")
p textReplace("&amp;")

and when you run it you should see it print

&amp;
&amp;

which is the behaviour you're looking for, and this works in the version before my changes.

sambowler commented 14 years ago

Strange, adding the textReplace gave me:

"&amp;"
"&amp;amp;"
hawx commented 14 years ago

Are you sure you've pulled and merged my changes fully?