-
Notifications
You must be signed in to change notification settings - Fork 92
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
AntiSamy converting single quotes to double quotes for font-family which is causing issue while rendering #200
Comments
@spassarop - Any ideas on whether we can fix this? |
Hi everyone! I debugged to detect where those quotes are added. When transforming CSS "lexical units" to CSS properties in the final string buffer that is the actual output, this particular case of a name between double quotes is taken as a case LexicalUnit.SAC_IDENT:
// just a string/identifier
String stringValue = lu.getStringValue();
if(stringValue.indexOf(" ") != -1)
stringValue = "\""+stringValue+"\"";
return stringValue; A possible fix is to switch Thinking about differences between being an inline style (as a HTML attribute) or being inside a whole I could just adapt the only failing test case and apply the proposed fix. If being more complex, I could internally pass the info that the tag is inline or not. Then, if it is inline, surround with |
@nahsra do you foresee any kind of conflict about this change? |
@spassarop any idea when this change is going to be published? |
@Gouravmoy @dplovelybuddy - This fix was just included in the v1.7.1 release that just went out. |
@davewichers Thanks for letting us know :) |
Hi,
I am using AntiSamy in my project. I am having an issue where AntiSamy is automatically converting single quotes to double quotes. This creates issues in case of rendering font family. Below is an example:
Below is the response:
The problem happens because of when I unescape this and send it to the UI, it becomes something like this
<p>Test <span style="font-family: "comic sans ms" , sans-serif;color: rgb(186,55,42);"><sup>~Nalla</sup></span></p>
Now the UI is not able to read the font family correctly because of the double quotes. It terminates after
<span style="font-family: "
. This is causing issue.I had asked the same question in SO some time ago - Link
The solution seems to be to either keep the font family in single quotes or keep the font family in double and whole
style
in single quotes. ReferencePlease let me know if you need any more information from my side. Also thanks in advance for looking into the issue.
The text was updated successfully, but these errors were encountered: