[ZEPPELIN-6534] Escape note name before building clone-name RegExp#5318
Open
kimyenac wants to merge 2 commits into
Open
[ZEPPELIN-6534] Escape note name before building clone-name RegExp#5318kimyenac wants to merge 2 commits into
kimyenac wants to merge 2 commits into
Conversation
Cloning a note whose name contains a regex metacharacter (e.g. `[`, `(`, or a trailing backslash) threw an uncaught SyntaxError when the clone dialog opened, because the note name was interpolated into the RegExp source unescaped in cloneNoteName(). The suggested clone name was never generated and the dialog was broken for that note. Escape regex metacharacters in the note-name prefix before constructing the RegExp so any note name is matched literally. Escaping is a no-op for names without metacharacters, so clone-name numbering is unchanged.
…ldren Opening any note logged an uncaught "TypeError: Cannot read properties of undefined (reading 'forEach')". In ngOnInit the queryParamMap subscription runs synchronously via startWith(), calling onParagraphSearch() before the @ViewChildren QueryList (listOfNotebookParagraphComponent) is populated, which only happens after ngAfterViewInit. Guard the call with optional chaining, consistent with the existing null handling elsewhere in this component. When the paragraph components are not yet rendered there is nothing to highlight, so skipping is safe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
Cloning a note whose name contains a regular-expression metacharacter (for example
[,(, or a trailing backslash) threw an uncaughtSyntaxErrorwhen the clone dialog opened, so the suggested clone name was never generated and the dialog was broken for that note.cloneNoteName()interpolated the note name directly into aRegExpsource without escaping it. This PR escapes the note name before building theRegExp, so any note name is matched literally.While verifying the fix in the running UI, a second, pre-existing defect surfaced in the same note view: opening any note logged an uncaught
TypeError: Cannot read properties of undefined (reading 'forEach'). InngOnInit, thequeryParamMapsubscription runs synchronously viastartWith()and callsonParagraphSearch()before the@ViewChildrenQueryList(listOfNotebookParagraphComponent) is populated (it is only available afterngAfterViewInit). This PR guards that call with optional chaining, consistent with the existing null handling elsewhere in the same component. It is included here as a small drive-by fix, in its own commit so it can be split out if preferred.What type of PR is it?
Bug Fix
Todos
RegExponParagraphSearch()against an uninitialized@ViewChildrenQueryListWhat is the Jira issue?
ZEPPELIN-6534
How should this be tested?
cd zeppelin-web-angular && npm run lintreport[2024(orfoo(bar) and click Clone: before the fix the dialog throwsSyntaxErrorand no name is suggested; after the fix it suggestsreport[2024 1and clones normally. Clone-name numbering for ordinary names is unchanged (escaping is a no-op when there are no metacharacters).forEachTypeErroris logged on load; after the fix the console is clean.Questions: