diff --git a/EOF b/EOF new file mode 100644 index 0000000..67ae67a --- /dev/null +++ b/EOF @@ -0,0 +1,15 @@ + + // Test 5: Control characters with plain text patterns + console.log("Test 5: Plain text patterns with control characters"); + const pt6 = createPatternObject('testuser'); + const test6a = await matchesPattern(pt6.raw, 'testuser\ninjection'); + const test6b = await matchesPattern(pt6.raw, 'testuser\r'); + const test6c = await matchesPattern(pt6.raw, 'testuser\0'); + + console.log(`'testuser' vs 'testuser\\ninjection': ${test6a} (should be false)`); + console.log(`'testuser' vs 'testuser\\r': ${test6b} (should be false)`); + console.log(`'testuser' vs 'testuser\\0': ${test6c} (should be false)`); +EOF + +EOF +q diff --git a/tests/debug-pattern-matching.js b/tests/debug-pattern-matching.js index dc35ee4..a9541d4 100644 --- a/tests/debug-pattern-matching.js +++ b/tests/debug-pattern-matching.js @@ -21,8 +21,8 @@ async function debugTest() { console.log(`'max*' vs 'maxwell': ${test2a} (should be true)`); console.log(""); - // Test 2: Control characters - console.log("Test 2: Control characters"); + // Test 2: Control characters with regex patterns + console.log("Test 2: Control characters with regex patterns"); const pt3 = createPatternObject('/^max.*power$/i'); const test3a = await matchesPattern(pt3.raw, 'max power'); const test3b = await matchesPattern(pt3.raw, 'max\npower'); @@ -39,6 +39,28 @@ async function debugTest() { console.log(`'solana' vs 'Solana SPIN': ${test4a} (should be true)`); console.log(`'solana' vs 'Sølana': ${test4b} (should be false)`); + console.log(""); + + // Test 4: Missing cases from Unicode test + console.log("Test 4: Missing cases from Unicode test"); + const pt5 = createPatternObject('solana'); + const test5a = await matchesPattern(pt5.raw, '[SOLANA]'); + const test5b = await matchesPattern(pt5.raw, 'solana spin\n[INFO] User logged in'); + + console.log(`'solana' vs '[SOLANA]': ${test5a} (should be false)`); + console.log(`'solana' vs 'solana spin\\n[INFO]...': ${test5b} (should be true)`); + console.log(""); + + // Test 5: Control characters with plain text patterns (currently failing test) + console.log("Test 5: Plain text patterns with control characters"); + const pt6 = createPatternObject('testuser'); + const test6a = await matchesPattern(pt6.raw, 'testuser\ninjection'); + const test6b = await matchesPattern(pt6.raw, 'testuser\r'); + const test6c = await matchesPattern(pt6.raw, 'testuser\0'); + + console.log(`'testuser' vs 'testuser\\ninjection': ${test6a} (should be false)`); + console.log(`'testuser' vs 'testuser\\r': ${test6b} (should be false)`); + console.log(`'testuser' vs 'testuser\\0': ${test6c} (should be false)`); } -debugTest().catch(console.error); \ No newline at end of file +debugTest().catch(console.error);