w3c / w3c/csswg-drafts

[css‑syntax] `<string‑token>` should probably handle valid surrogate pairs

Open
#6,352 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-syntax-3
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

Spec: https://drafts.csswg.org/css-syntax-3/#consume-string-token


The 6 digit syntax for <string‑token> was only added to CSS in CSS2, with the CSS Syntax module restricting it to not allow surrogate code points, but I would expect that a string containing valid surrogate pairs would work like the equivalent 6 digit syntax, e.g.:

.foo:before {
	/*
	The "CSS1" and "CSS2.1" specifications parse this as:
		- U+D83D (High Surrogate)
		- U+DD25 (Low Surrogate)

	The "CSS Syntax Level 3" specification parses this as:
		- U+FFFD (Replacement Character)
		- U+FFFD (Replacement Character)

	I would expect this to parse as the U+D83D and U+DD25 surrogate code points,
	which would decode to U+1F525 (Fire) at parse time.
	*/
	content: "\D83D\DD25";
}

and

.foo:before {
	/*
	The "CSS1" specification parses this as:
		- U+1F52 (Greek Small Letter Upsilon With Psili And Varia)
		- U+35 (Digit Five)
	The "CSS2.1" and "CSS Syntax Level 3" specifications parse this as:
		- U+1F525 (Fire)
	*/
	content: "\1F525";
}

would be equivalent.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked CSS Syntax Level 3 section on consuming string tokens and compare its treatment of surrogate code points with the examples in the issue. The issue asks whether valid surrogate pairs should be handled differently; done would require a resolved specification decision and any corresponding draft change, but no implementation files or tests are named.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.