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
Invalid CSS raises error starting in 1.8.0 #125
Comments
kinda like the new behavior more, but it would be nice if it raised a more descriptive error ... |
We're having a similar issue where the upgrade from 1.7.1 to 1.9.0 has started raising exceptions like the following:
I haven't been able to reduce this to a minimal example but I'll report back when I get one. |
I've pushed a PR that fixes the issue I had in #126. I believe these issues aren't related so perhaps I ought to open up a new issue, but when I commented yesterday I thought it might be an overall-sort-of-parsing issue before I actually decided to try and fix the issue. At any rate, the PR fixes the |
if calc worked before then something went wrong during refactoring and we should be able to undo that ? |
@grosser It never really worked, but it was often silently ignored until the commit in 8868aa6, specifically with this code: https://github.com/premailer/css_parser/blob/master/lib/css_parser/rule_set.rb#L373 The issue being if the value is being split on whitespace using commas as parameter separators, then the However, if you did {
"margin-left" => "calc(1em/4*4)",
"margin-right" => "calc(1em/4*4)",
"margin-top" => "calc(1em/4*4)",
"margin-bottom" => "calc(1em/4*4)"
} Which is correct, but only because of the lack of whitespace in the "margin: calc(1em / 4)"
{
"margin-top" => "calc(1em",
"margin-right" => "/",
"margin-bottom" => "4)",
"margin-left" => "/"
}
"margin: calc(1em /4)"
{
"margin-top" => "calc(1em",
"margin-right" => "/4)",
"margin-bottom" => "calc(1em",
"margin-left" => "/4)"
}
"margin: calc(1em / 4 * 4)"
# in current master
ArgumentError (Cannot parse calc(1em / 4 * 4))
"margin: calc(1em / 4 * 4)"
# in v1.7.1:
{}
# With commas:
"margin: clamp(1rem, 2.5vw, 2rem)"
{
"margin-top" => "clamp(1rem,",
"margin-right" => "2.5vw,",
"margin-bottom" => "2rem)",
"margin-left" => "2.5vw,"
} With my PR, the expected values are expanded: "margin: calc(1em / 4)"
{
"margin-top" => "calc(1em / 4)",
"margin-right" => "calc(1em / 4)",
"margin-bottom" => "calc(1em / 4)",
"margin-left" => "calc(1em / 4)"
}
"margin: calc(1em /4)"
{
"margin-top" => "calc(1em /4)",
"margin-right" => "calc(1em /4)",
"margin-bottom" => "calc(1em /4)",
"margin-left" => "calc(1em /4)"
}
"margin: calc(1em / 4 * 4)"
{
"margin-top" => "calc(1em / 4 * 4)",
"margin-right" => "calc(1em / 4 * 4)",
"margin-bottom" => "calc(1em / 4 * 4)",
"margin-left" => "calc(1em / 4 * 4)"
}
"margin: clamp(1rem, 2.5vw, 2rem)"
{
"margin-top" => "clamp(1rem, 2.5vw, 2rem)",
"margin-right" => "clamp(1rem, 2.5vw, 2rem)",
"margin-bottom" => "clamp(1rem, 2.5vw, 2rem)",
"margin-left" => "clamp(1rem, 2.5vw, 2rem)"
} So basically The |
Can we return to the question at hand? Or is there a way to go back to pre-1.8.0 functionality (i.e. letting invalid CSS pass) using an argument or something? |
@grosser pinging on this. is there a way to pass something so that we can return to the pre-1.8.0 functionality? |
removing the raise would do the trick ? |
Hey folks, I'm experiencing something similar where emails contain invalid margin or padding (e.g. 5 values instead of 4, 3, 2 or 1).
In my case, it would be good to ignore these invalid styles too. Is the current workaround to use a pre-1.8.0 version of this gem? |
I can confirm that in my case, |
PR welcome ... would love a unified solution, but as long as the default is "what works for most ppl / is intuitive" 🤷 |
PR that allows option passing to mute the exception here: #132 |
1.12.0 |
allows setting |
Not sure what the general strategy is in this gem for handling invalid CSS, but the behaviour changed between 1.7.1 and 1.8.0.
In 1.7.1:
In 1.8.0:
The text was updated successfully, but these errors were encountered: