mathiasbynens / mathiasbynens/CSS.escape
Double escaping?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 499
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
Not sure if this makes sense when having the escape spec in mind (you know that way better!), but what if a character is already escaped within the string to escape? The current code will double escape escaped stuff, I'm using a custom version that doesn't do that, e.g. changed to this:
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `\` (U+005C) or
// `_` (U+005F), or is preceded by a `\` (escape) already,
// or is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit == 0x002D ||
codeUnit == 0x005C || // custom: no double escapes!
codeUnit == 0x005F ||
string.charCodeAt(index-1) == 0x005C || // custom: no double escapes!
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}
if this makes any sense for this project I'm glad to open a PR with the change, but I can imagine it is either against the spec, the purpose of this module or will break backward compatibility and can therefore not be done...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current CSS.escape implementation and comparing its handling of already escaped characters with the CSSOM specification. Determine whether avoiding double escaping is correct for this project and whether it preserves backward compatibility. Done means reaching a specification-backed decision and documenting or implementing the agreed behavior with appropriate regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100