Skip to content

xxx-large font-size is discarded when allowStyling() is used #291

Closed
@Ashish-Singh-B

Description

@Ashish-Singh-B

I am sanitazing the input using the default CssSchema and discovered that xxx-large font size is not supported in allowed font-sizes in styling

ImmutableSet<String> fontLiterals1 = ImmutableSet.of(
        "large", "larger", "small", "smaller", "x-large", "x-small",
        "xx-large", "xx-small");

I tried various ways like

  1. union of custom CssSchema with just xxx-large font-size along with default CssSchema but it results as
Caused by: java.lang.IllegalArgumentException: Duplicate irreconcilable definitions for font-size
	at org.owasp.html.CssSchema.union(CssSchema.java:199)
  1. I also tried creating customHTMLPolicyBuilder with allowAttributes settings but it seems to be applied after the font-size is removed by CssSchema
CustomerHtmlPolicyBuilder.allowAttributes("style").matching(Pattern.compile("font-size:xxx-large"))
            .onElements("span")

please let me know how to proceed with font-size as xxx-large as it's a valid size and supported in various browsers

Example :

String to sanitize: 
the <span style="font-size:xxx-large">large</span> formatting issue with chrome

Expected: (same as above as all valid configurations)
the <span style="font-size:xxx-large">large</span> formatting issue with chrome

Actual: 
the large formatting issue with chrome

the large formatting issue with chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions