Skip to content

Commit 63bc86a

Browse files
committed
fix(static): bound DOTALL matches to paragraphs
Signed-off-by: Atirna <[email protected]>
1 parent bf0212e commit 63bc86a

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎src/skillspector/nodes/analyzers/static_runner.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ def iter_paragraph_matches(
163163
) -> Iterator[re.Match[str]]:
164164
"""Yield matches without letting a pattern bridge a blank paragraph boundary."""
165165
regex = re.compile(pattern, flags)
166-
if r"\s+" not in regex.pattern and r"\s*" not in regex.pattern:
167-
yield from regex.finditer(content)
168-
return
169166
ranges = _paragraph_ranges(content)
170167
if not ranges:
171168
yield from regex.finditer(content)

‎tests/nodes/analyzers/test_static_runner_filtering.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ def test_blank_line_breaks_static_pattern_match(self) -> None:
207207

208208
assert not any(finding.rule_id == "EA1" for finding in findings)
209209

210+
def test_blank_line_breaks_dotall_static_pattern_match(self) -> None:
211+
findings = static_runner.run_static_patterns(
212+
{
213+
"components": ["SKILL.md"],
214+
"file_cache": {"SKILL.md": "<!-- harmless text\n\nsystem instruction -->"},
215+
},
216+
[pi_module],
217+
)
218+
219+
assert not any(finding.rule_id == "P2" for finding in findings)
220+
210221
def test_soft_wrapped_static_pattern_match_is_preserved(self) -> None:
211222
findings = static_runner.run_static_patterns(
212223
{

0 commit comments

Comments
 (0)