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

Escape - in editorconfig section name #52620

Closed
Youssef1313 opened this issue Apr 14, 2021 · 3 comments
Closed

Escape - in editorconfig section name #52620

Youssef1313 opened this issue Apr 14, 2021 · 3 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@Youssef1313
Copy link
Member

The - character has special meaning, which I think will need to be escaped as well. It's not specified in editorconfig docs, but used in Roslyn. See:

case '-':
// '-' means the same thing in regex as it does in the glob, so
// put it in verbatim
sb.Append(currentChar);
break;

Related to #52515

FYI @captainsafia

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 14, 2021
@captainsafia
Copy link
Member

My 2 cents: since the - is already handled as a standard character in the case above, I don't think we need to worry about escaping it. It makes sense to me to escape only the things that would be considered as special characters by editorconfig itself otherwise and - is not one of those.

@Youssef1313
Copy link
Member Author

the - is already handled as a standard character in the case above

@captainsafia I don't think this is correct. The string builder used in the case above holds the Regex pattern that will be used for matching section names. The - has special meaning in Regex. So I'd expect a file called "A-Z.cs" to have an issue, since the generated regex will potentially look for a single uppercase letter from A to Z instead of the literal "A-Z". But will need to confirm before doing the change.

@Youssef1313
Copy link
Member Author

I dug more into this. Since the - has special meaning only between [ ] in section name, and since GenerateMSBuildEditorConfig task won't add un-escaped [ ] in section name, there is no need to escape the dash. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants