Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with backarrow #193

Closed
gruvw opened this issue Jun 13, 2024 · 4 comments
Closed

Error with backarrow #193

gruvw opened this issue Jun 13, 2024 · 4 comments

Comments

@gruvw
Copy link

gruvw commented Jun 13, 2024

I ran into an error while using this minifier on strings of the following form: <a><- H</a>

Expected behavior:
image

Actual behavior:
image

Minimal reproduce:

from minify_html import minify

print(minify("<a><- H</a>"))  # `<a><- a h<>`
@chrispy-snps
Copy link

chrispy-snps commented Jun 13, 2024

@gruvw - I don't think this is a bug. While > characters can optionally be encoded into HTML &gt; entities, < characters must be encoded into HTML &lt; entities so they are not mistaken for the beginning of a tag.

This should work for you:

from minify_html import minify

print(minify("<a>&lt;- H</a>"))  # `<a><- a h<>`

except that bug #191 prevents this from working properly.

@gruvw
Copy link
Author

gruvw commented Jun 18, 2024

Well, on a conceptual level, from the point of view of the user of a minifier, I would assume that I get the same output with or without using the minifier.

In that particular case, I got a different result by using the minifier (thus the reason why I called it a bug/error).

I am not very familiar with this particular project (minify-html), but it's a general rule that I tend to apply.
If it does not apply here and there are edge cases of that sort, is there a documented list of common pitfalls and how to fix them ?

@chrispy-snps
Copy link

@gruvw - for any utility that processes input, I think it's fair to expect uncertain output behavior for invalid inputs.

You can verify that this input is invalid by going to the W3C Markup Validation Service page and checking this HTML:

<!DOCTYPE html>
<html lang="en">
 <head><title>title</title></head>
 <body>
  <p><a><- H</a></p>
 </body>
</html>

@gruvw gruvw closed this as completed Jun 18, 2024
@gruvw
Copy link
Author

gruvw commented Jun 19, 2024

I generally prefer the utility to error instead of silently producing uncertain output, but I got your point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants