Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\xHH escapes in string literal are expanded #1508

Closed
1 of 3 tasks
vain0x opened this issue Mar 6, 2021 · 2 comments · Fixed by #1509
Closed
1 of 3 tasks

\xHH escapes in string literal are expanded #1508

vain0x opened this issue Mar 6, 2021 · 2 comments · Fixed by #1509

Comments

@vain0x
Copy link
Contributor

vain0x commented Mar 6, 2021

Issue created from fantomas-online

Code

"\x00"

Result

""

Problem description

Hex escapes that look like \xHH in string literals are expanded to the escaped characters.

Extra information

  • The formatted result breaks by code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas Master at 03/05/2021 14:51:06 - 69fd7ea

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

vain0x added a commit to vain0x/fantomas that referenced this issue Mar 6, 2021
@nojaf
Copy link
Contributor

nojaf commented Mar 6, 2021

Hello @vain0x, thank you for reporting this issue.
I believe it can be solved by adding x to this regex:

let escapedCharacterRegex =
System.Text.RegularExpressions.Regex("(\\\\(n|r|u|'|\\\"|\\\\))+")

Would you be interested in submitting a PR?

@vain0x
Copy link
Contributor Author

vain0x commented Mar 6, 2021

Thank you. I have submitted a PR.

vain0x added a commit to vain0x/fantomas that referenced this issue Mar 6, 2021
nojaf pushed a commit that referenced this issue Mar 6, 2021
* Keep hex escapes in string literals (#1508)

* Add more patterns to escapedCharacterRegex (#1508)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants