-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathtest_issue_207.py
More file actions
23 lines (18 loc) 路 752 Bytes
/
Copy pathtest_issue_207.py
File metadata and controls
23 lines (18 loc) 路 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
import hyperscan
print(f'hyperscan version: {hyperscan.__version__}')
# Exact code from GitHub issue #207
bla = [r'<span\s+.*>丕賱爻賱丕賲 毓賱賷賰賲\s<\/span>'.encode('utf8'),
r'<span\s+.*>讜注诇讬讻讜诐 讛住诇讗诐\s<\/span>'.encode('utf8')]
print(f'Testing patterns: {bla}')
try:
rules_db = hyperscan.Database()
rules_db.compile(expressions=bla,
flags=hyperscan.HS_FLAG_UTF8 | hyperscan.HS_FLAG_UCP)
print('SUCCESS: Patterns compiled with HS_FLAG_UTF8 | HS_FLAG_UCP!')
except Exception as e:
print(f'FAILED: {e}')
if 'Expression is not valid UTF-8' in str(e):
print('*** THIS IS THE EXACT BUG FROM ISSUE #207! ***')
else:
print('*** Different error ***')