Fix browser crash when @Highlight value is empty string - #186
Fix browser crash when @Highlight value is empty string#186michaelomichael wants to merge 2 commits into
Conversation
buildHighlightRegex has two further callers, DataTable and FixturesTable, which pass the result straight to String.split. Returning null broke tsc for both, and at runtime they guard on highlights.length === 0, which does not catch [""], so split(null) coerced to the string "null" and swallowed that word wherever it appeared. (?!) can never match, so split returns the whole string and test is false. That keeps the RegExp return type and fixes all three call sites without threading null through any of them. Adds tests, which this function had none of.
|
Good find, the diagnosis is spot on: an empty highlight builds a regex that matches every text node and hangs the tab. One wrinkle. You're busy, so I've pushed a commit rather than bounce it back. It returns CI was green on your original despite Thanks for both of these. |
|
Looks good. |
Having a field/parameter annotated with
@Highlightcan cause the browser tab to crash when the value of that field/parameter is an empty string ("").This is because the generated "highlight" regex pattern will match every single text node due to it matching on the empty string.
This fix ignores any zero-length "highlight" values.