aboutcode-org / aboutcode-org/scancode-toolkit

Broken regexp in is_relative_path()

未关闭
#531 12 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug text extraction
主要语言
Python
星标
2.6k
派生
791
平均合并
1 天 12 小时
30 天内合并 PR
5

描述

`textcode.strings.is_relative_path()` is completely broken:

```pycon
>>> from textcode.strings import is_relative_path
>>> is_relative_path("/usr")
Traceback (most recent call last):
File "", line 1, in
File "/home/jwilk/.local/lib/python2.7/site-packages/textcode/strings.py", line 200, in
relative = re.compile('^(?:([^/]|\.\.)[\w_\-]+/.*$', re.IGNORECASE).match
File "/usr/lib/python2.7/re.py", line 194, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.7/re.py", line 251, in _compile
raise error, v # invalid expression
sre_constants.error: unbalanced parenthesis
```

Tested against git HEAD (bca0af4a6ff10f4ef0bef6459f2f06a17d21f9f6).

Found using [pydiatra](https://github.com/jwilk/pydiatra).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。