google / google/closure-templates

rgb()/rgba() CSS color values not supported in filterCssValue

Open
#49 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
700
Forks
199
Avg merge
2d 12h
Merged PRs (30d)
26

Description

I am running into following error when using `rgb(...)` or `rgba(...)` in CSS color values with strict autoescaping.

`Uncaught AssertionError: Failure: Bad value `rgba(0,0,0,0.6)` for |filterCssValue`

Testing template:

```
{namespace test}

{template .item}
{@param? style: [color: string]}


test

{/template}

{template .style private="true" kind="css"}
{@param? style: [color: string]}

{if $style.color}background-color: {$style.color};{/if}
{/template}
```

To reproduce, it can be called with following JS code:

``` lang=js
test.item({
style = {
color: 'rgba(0, 0, 0, 0.6)'
}
});
```

The culprit seems to be this [regular expression](https://github.com/google/closure-templates/blob/50a0b6950bbe65cdd9d611db2e4ad690c0de4318/java/src/com/google/template/soy/shared/restricted/EscapingConventions.java#L818) and in turn this generated [JS code](https://github.com/google/closure-templates/blob/e049b2e673a5a9571aaa088f4c6d2d434d444d7b/javascript/soyutils_usegoog.js#L2153).

I can supply PR if interested.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.