Commit a34dfca
authored
fix(timestamp): escape live table-cell pipe after an escaped backslash (#227)
escapeForTableCell used a `(?<!\\)\|` lookbehind that treated any pipe
preceded by a backslash as already escaped. The sequence `\\|` (an escaped
backslash followed by a genuinely live pipe) slipped through unescaped, so
the pipe stayed active and broke the markdown table row when a captured
timestamp landed in a table cell. Adjacent pipes (`||`) had the same class
of gap.
Key the escape on the parity of the preceding backslash run instead: a pipe
is already escaped only when it follows an odd-length run of backslashes, so
an even-length run (including zero) is escaped exactly once. This neutralizes
a pipe inside a table cell regardless of any preceding backslashes while
leaving genuinely-escaped pipes untouched.
Adds unit tests for the escaped-backslash-then-pipe (`a\\|b`), odd-run
(`a\\\|b`), and adjacent-pipe (`a||b`) cases.
Resolves deepsec finding other-escaping-gap-3d20dd1596.1 parent a5683db commit a34dfca
2 files changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
94 | 112 | | |
95 | 113 | | |
96 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
86 | 96 | | |
87 | 97 | | |
88 | 98 | | |
| |||
0 commit comments