Repository navigation
tokenizer: Fix ident start check for a hyphen before an invalid escape. - #466
NoobInTheNet wants to merge 1 commit into
Conversation
For `-\`, is_ident_start looked for the newline at offset 1, which is the backslash itself, so `-\<newline>` started an identifier. The newline is at offset 2. Fixes servo#440 Assisted-by: Claude Code (claude-fable-5-2)
|
@mrobinson, you closed this without a word. If the reason is the AI Usage Policy, please say so. One line from you would have cost less than this fix cost me. The PR is a one-line fix in A reviewer can check it all in two minutes, and it would have counted as good practice long before LLMs existed. What do you expect, that I retype a 19-line diff by hand and write the same 650 characters again? I'm all for the social responsibility behind your policy. I know Igalia has 25 years behind it, a lot of them on embedded browsers like WPE WebKit. I get the old-school instinct that comes with that, up to a point. I also see why open-source projects are wary of AI PRs: they're usually messy and sloppy, and they burn reviewer time. This PR is none of that, though, and the policy treats it the same. I've written code for over 12 years, most of it by hand, well before coding assistants existed. An LLM made it quick to trace a tokenizer bug from 2014 and turn it into a tested patch. That bug has sat for almost 12 years in the most downloaded CSS parser on crates.io, which has about 130 million downloads. Accessibility isn't only physical, and our field is full of unique profiles and non-linear thinkers. For me, an LLM puts structure on my thoughts and helps me carry them through. It also makes the result easier for reviewers like you to follow. The only thing a blanket ban achieves here is that people lose the will to contribute. Your TSC keeps coming back to this. In early 2025 it reviewed a Copilot trial that had produced @SimonSapin @emilio, you made the policy explicit for this crate in #465. On #464, Emilio wrote: "I'd personally be ok with AI-generated code as long as the author is accountable for it / understands it (and defends it as needed with human words)." I'm that author, and I'll answer any question about this change myself. I'd like it reopened for review. Thanks for reading all of it. I know parts sound hard, and I apologize in advance if they hurt anyone, because that was never my aim. If you still think rejecting these contributions is the right path, it's your call. In that case I'll put my effort into Rust CSS parsers that accept disclosed AI help, such as swc's With much love, from the southeast coast of Spain (Alicante) to the northwest one (Galicia) 👋😉. Note And yes, I drafted this comment with an LLM again. I find structuring my thoughts challenging with ADHD. By hand, this would take much more time and effort. The message would likely end up even more confusing, too. The points are mine, and so is the decision to post it. |
I don't think there's anything to discuss here. You know what the policy is and you invited us to close the PR, and we did. |
Fixes #440.
In the
-arm ofis_ident_start, the check for an invalid escape looked for the newline at offset 1. That byte is the backslash itself, so the check never fired and-\<newline>started an identifier. The newline is at offset 2.Per CSS Syntax §4.3.9,
-followed by\starts an ident sequence only if the backslash begins a valid escape. A backslash before a newline does not.Hash, at-keyword and dimension tokens use the same check, so the test covers
-\,@-\,#-\and1-\before a newline. css-tokenizer-tests has the first one astests/ident/0004.Note
AI disclosure: this bug turned up while I was moving the CSS scan of rustywind to
cssparserin avencera/rustywind#168. I did that work with Claude Code and its model Claude Fable 5.2. The tool wrote this patch and drafted this description. I have read the change, run the tests, and can explain it. I know the AI Usage Policy says no as written, so close this if you prefer. Someone else can then write the fix.