I have a simple apps-script that uses the html service and I need the :after pseudo-selector .
Boiling down the issue to a line of code, I have
<style>
test:after {
content: attr(data-hidden);
display: inline-block;
font-weight: bold;
}
</style>
<test data-hidden="Now you don't">Now you see me </test>
Per jsfiddle, the expected output would be "Now you see me Now you don't", but I only get "Now you see me"
If I remove the :after I get Now you see me, as expected.
FWIW I am using .setSandboxMode(HtmlService.SandboxMode.NATIVE)
Can anyone tell me what I am doing wrong?
The
content: attr()
line is being stripped by the caja compiler. Try your code snippet on the Caja Playground, and inspect the Rendered Result, which should be a better representation of how HTML will be sanitized when served from Google Apps Script than you'll get at jsfiddle.Here's what is rendered:
The
data-hidden
attribute of the<test>
tag survives, but there's nocontent
attribute in the style to contain it. That's probably because theattr()
statement appears to be an attack vector. (example)If we try again with a constant
content
, it survives cajoling:Because of the sanitization, you're not going to be able to make
attr()
work this way. You could enter an issue on the Caja Issue Tracker.