caddyserver / vscode-caddyfile

Rich Caddyfile support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=matthewpi.caddyfile-support
MIT License
79 stars 3 forks source link

Highlighting breaks on escaped double-quote #303

Open francislavoie opened 1 month ago

francislavoie commented 1 month ago

This file breaks at the \""" part on line 20

https://github.com/caddyserver/caddy/blob/3afa02ba4e5bee5628ee9334a64a0002a102a60b/caddytest/integration/caddyfile_adapt/map_and_vars_with_raw_types.caddyfiletest#L20

I realize this is kinda weird, but I think what ends up happening with this syntax is that the escaped doublequote \" gets read in as token value, then the next character being a plain " turns on the "we're in a quoted token now" and doesn't write it to the value, and finally the last " closes the "we're in a quoted token now" flag and since nothing came in between it's just an empty value. Arguably it shouldn't be allowed for a non-escaped " to follow an escaped " at the start, but that is now it behaves right now.

Also a simple \" (without the 2 extra double-quotes) also breaks highlighting, so at minimum escaped double-quotes aren't handled totally correctly.

Ultimately a very minor issue, no rush on fixing this :sweat_smile: