Fix escaping when converting Lua patterns in queries.
Review Request #15405 — Created Oct. 19, 2026 and submitted
When we rewrite
lua-match?predicates andgsub!directives into
Python regexes, we pulled the pattern out of the query string by
stripping the quotes. This never un-escaped the string first. A pattern
containing an escaped quote, like"^@\"<html", came out as
"^@\\\\"<html", which ends the string early and breaks the query.
update-queries.pyvalidates queries before writing them, so these
failures were silent. Affected files were either dropped or fell back to
an older commit. This is why we were missing injections for
git_config,nix, andteal, and whysystemtapandt32were
stuck on old highlights.Query strings are now un-escaped before conversion and re-escaped
afterward.This exposed a second problem.
lua_pattern_to_python()treated a
backslash followed by a regex special character as an escape that had
already been done, and passed it through. That only worked because it
was being given the still-escaped query string. Backslashes have no
special meaning in Lua patterns, so they're now always treated as
literal characters. Without this, t32's pattern for 6 literal
backslashes would have turned into a pattern for 3.
- Ran unit tests.
- Added a test for converting a pattern with an escaped quote.
- Re-ran
update-queries.pyand verified that the missing files came
back and that the regenerated queries all load. - Checked that the regenerated t32 pattern matches the same text as
the original Lua pattern.
| Summary | ID |
|---|---|
| wrqormtvyxplytvlvswkzlukwyrzxsnn |
| Description | From | Last Updated |
|---|---|---|
|
We got rid of block 2 so now this and the rest of the blocks need to be renumbered. |
|