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

Breaks when > is in a script or style tag #21

Open
jenstornell opened this issue Aug 19, 2018 · 6 comments
Open

Breaks when > is in a script or style tag #21

jenstornell opened this issue Aug 19, 2018 · 6 comments

Comments

@jenstornell
Copy link
Owner

Below will break.

<script>
    console.log('Script > are not minified');
    console.log('This is inside a script tag');
</script>
@EdixonAlberto
Copy link
Contributor

I do not understand very well what is this for.

@jenstornell
Copy link
Owner Author

@EdixonAlberto When having an inline script, it breaks in some cases when > character is used because it's also used for open/closing html tags.

@buraksahin59
Copy link

There is the same issue in inline style tag.

<style>
    .fa-ul > li{position:relative}
</style>

@jenstornell jenstornell changed the title Breaks when > is in a script tag Breaks when > is in a script or style tag Aug 30, 2019
@ozupey
Copy link

ozupey commented Apr 4, 2020

Is there any solution for this? It happens even if style is inside elements->skip.

@go-vegan
Copy link

go-vegan commented May 29, 2020

I just found your script and wanted to use it in production.
Too bad it broke our inline javascript, so I had to take it down :(

<script>
  a > b ? 'YES' : 'NO';
</script>

becomes:

<script>
  a </script>

< also gets trailing spaces removed, even inside quotes.

@bhenk
Copy link

bhenk commented Jul 11, 2020

Related to this (?): Removes 'unneeded' self slash in function removeSelfSlash. This will kill some svg.

<rect width="14vw" height="15vw" style="fill:rgb(0,0,0);stroke-width:3;stroke:rgb(0,0,0)" />

becomes

<rect width="14vw" height="15vw" style="fill:rgb(0,0,0);stroke-width:3;stroke:rgb(0,0,0)">

.. and stops the rest of the svg from being renderd.

Matthew-Kilpatrick added a commit to Matthew-Kilpatrick/tiny-html-minifier that referenced this issue Feb 27, 2021
Fix contnet of element body being truncated after first occurrence
of a greater than sign (>), which can cause issues in some circumstances,
such as a conditional evaluation inside a script tag.

Relates to issue jenstornell#21
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

6 participants