Skip to content

fix: Parse character, octal, and hex string escapes - #2426

Open
jiang1997 wants to merge 1 commit into
protobufjs:masterfrom
jiang1997:fix/proto-string-escapes
Open

fix: Parse character, octal, and hex string escapes#2426
jiang1997 wants to merge 1 commit into
protobufjs:masterfrom
jiang1997:fix/proto-string-escapes

Conversation

@jiang1997

Copy link
Copy Markdown
Contributor

Support additional protobuf character escapes, including escaped quotes, plus bounded octal and hexadecimal escapes. Add tests for parsed defaults and numeric escape boundaries.

Unicode escapes and validation of malformed or unknown escapes remain unsupported.

Support additional protobuf character escapes, including escaped quotes, plus bounded octal and hexadecimal escapes. Add tests for parsed defaults and numeric escape boundaries.

Unicode escapes and validation of malformed or unknown escapes remain unsupported.
@alexander-fenster

Copy link
Copy Markdown
Contributor

@jiang1997 Do you know what's the behavior of the protoc parser for these cases? I can probably go figure out but if you have a pointer to their code or docs that would've been handy :)

@jiang1997

Copy link
Copy Markdown
Contributor Author

@alexander-fenster Yes. I used the protobuf string literal grammar and protoc's tokenizer as references:

protoc consumes up to three octal digits and two hexadecimal digits. I also verified that the parsed defaults match protoc's output.

@jiang1997

Copy link
Copy Markdown
Contributor Author

Separately, Unicode escapes (\uXXXX and \UXXXXXXXX) are still missing. I think supporting them would be cleaner with a small character-by-character scanner instead of extending the current regex.

Would that make sense for a follow-up PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants