Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions changelog.d/unreleased/1624.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
category: fixed
issues:
- 1624
affected:
- src/CodeIndex/Indexer/Scanning/FileIndexer.cs
- tests/CodeIndex.Tests/FileIndexerTests.cs
---

## English

- **Reversed ignore character ranges are now rejected (#1624)** — `.gitignore` and `.cdidxignore` patterns such as `[z-a]` are skipped with a warning instead of compiling into a matcher that silently matches nothing.

## 日本語

- **ignore ルールの逆順文字範囲を拒否するようにしました (#1624)** — `.gitignore` と `.cdidxignore` の `[z-a]` のような pattern は、何にも一致しない matcher として静かに受理されず、警告付きで skipped されます。
3 changes: 3 additions & 0 deletions src/CodeIndex/Indexer/Scanning/FileIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ private static void AppendCharacterClassLiteral(StringBuilder builder, char ch,

private static bool TryAppendCharacterClassRange(StringBuilder builder, char start, char end, bool ignoreCase)
{
if (start > end)
throw new ArgumentException("reversed character class range");

builder.Append(EscapeCharacterClassLiteral(start));
builder.Append('-');
builder.Append(EscapeCharacterClassLiteral(end));
Expand Down
1 change: 1 addition & 0 deletions tests/CodeIndex.Tests/FileIndexerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,7 @@ public void ScanFilesDetailed_SkipsMalformedIgnoreRulesWithoutAborting()
Assert.Equal(7, scanResult.Errors.Count);
Assert.All(scanResult.Errors, error => Assert.Contains(".gitignore:", error.Path, StringComparison.Ordinal));
Assert.All(scanResult.Errors, error => Assert.Contains("Invalid ignore rule skipped", error.Message, StringComparison.Ordinal));
Assert.Contains(scanResult.Errors, error => error.Message == "Invalid ignore rule skipped: reversed character class range");
Assert.All(scanResult.Errors, error => Assert.Equal(FileIndexer.ScanIssueSeverity.Warning, error.Severity));
}
finally
Expand Down
Loading