Description
The regex input field in ExtractFields.tsx has incomplete character escaping that can corrupt regex patterns containing backslashes.
Current Implementation
Display (line 771):
value={part.regexDef?.replace(/\r/g, '\\r').replace(/\n/g, '\\n')}
Input handling (lines 775-777):
const rawValue = e.target.value
.replace(/\\r/g, '\r')
.replace(/\\n/g, '\n');
Problem
The code only escapes \r and \n characters but doesn't escape backslashes themselves. This causes issues when regex patterns contain:
\d (digit matcher)
\. (literal dot)
\\ (literal backslash)
- Any other escaped regex characters
Expected Behavior
Backslashes should be escaped when displaying and unescaped when parsing input.
Proposed Fix
// Display: escape backslashes FIRST, then handle \r and \n
value={part.regexDef?.replace(/\\/g, '\\\\').replace(/\r/g, '\\r').replace(/\n/g, '\\n')}
// Input: reverse the process - handle \r and \n FIRST, then unescape backslashes
const rawValue = e.target.value
.replace(/\\r/g, '\r')
.replace(/\\n/g, '\n')
.replace(/\\\\/g, '\\');
Note: The order matters! Backslashes must be escaped first when displaying, and unescaped last when parsing.
Location
Description
The regex input field in
ExtractFields.tsxhas incomplete character escaping that can corrupt regex patterns containing backslashes.Current Implementation
Display (line 771):
Input handling (lines 775-777):
Problem
The code only escapes
\rand\ncharacters but doesn't escape backslashes themselves. This causes issues when regex patterns contain:\d(digit matcher)\.(literal dot)\\(literal backslash)Expected Behavior
Backslashes should be escaped when displaying and unescaped when parsing input.
Proposed Fix
Note: The order matters! Backslashes must be escaped first when displaying, and unescaped last when parsing.
Location