Skip to content

CSS Processor string token values mishandle backslash-newline #222

@sirreal

Description

@sirreal

In CSS <string> token values, WordPress\DataLiberation\CSS\CSSProcessor::get_token_value() reports an incorrect token value for \ + \n (it should be ignored in the token value).

See the rules for consuming a string token:

Repeatedly consume the next input code point from the stream:

U+005C REVERSE SOLIDUS (\)

Related to #223.


Demo

$p = WordPress\DataLiberation\CSS\CSSProcessor::create( "'str\\\ning'" );
$p->next_token();
assert( $p->get_token_type() === WordPress\DataLiberation\CSS\CSSProcessor::TOKEN_STRING );
assert( $p->get_token_value() === 'string', 'Expected "string", got ' . var_export( $p->get_token_value(), true ) );

Will throw AssertionError: Expected "string", got 'str\\\ning'.


Example of string value equality

"A\\nB" === "AB"

This should render with a fancy font, <i>not monospace</i>.
<style>
/* Note that the two "AB" strings match. */
body { font-family: 'A\
B', monospace;}
@font-face {
  src: url(https://fonts.gstatic.com/s/lobster/v32/neILzCirqoswsqX9zoKmM4MwWJU.woff2) format('woff2');
  font-family: 'AB';
}
</style>

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions