-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathtest_without_flags.py
More file actions
38 lines (31 loc) ยท 1.31 KB
/
test_without_flags.py
File metadata and controls
38 lines (31 loc) ยท 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import hyperscan
print(f'hyperscan version: {hyperscan.__version__}')
# Same patterns from GitHub issue #207 but WITHOUT the problematic flags
bla = [r'<span\s+.*>ุงูุณูุงู
ุนูููู
\s<\/span>'.encode('utf8'),
r'<span\s+.*>ืืขืืืืื ืืกูืื\s<\/span>'.encode('utf8')]
print(f'Testing patterns: {bla}')
print('\n=== Testing WITH problematic flags (should fail) ===')
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}')
print('\n=== Testing WITHOUT flags (should work) ===')
try:
rules_db = hyperscan.Database()
rules_db.compile(expressions=bla)
print('SUCCESS: Patterns compiled without flags!')
except Exception as e:
print(f'FAILED: {e}')
print('\n=== Testing with unicode strings (should work) ===')
try:
unicode_patterns = [r'<span\s+.*>ุงูุณูุงู
ุนูููู
\s<\/span>',
r'<span\s+.*>ืืขืืืืื ืืกูืื\s<\/span>']
rules_db = hyperscan.Database()
rules_db.compile(expressions=unicode_patterns)
print('SUCCESS: Unicode patterns compiled without flags!')
except Exception as e:
print(f'FAILED: {e}')