Skip to content

[ZEPPELIN-6534] Escape note name before building clone-name RegExp#5318

Open
kimyenac wants to merge 2 commits into
apache:masterfrom
kimyenac:ZEPPELIN-6534
Open

[ZEPPELIN-6534] Escape note name before building clone-name RegExp#5318
kimyenac wants to merge 2 commits into
apache:masterfrom
kimyenac:ZEPPELIN-6534

Conversation

@kimyenac

Copy link
Copy Markdown
Contributor

What is this PR for?

Cloning a note whose name contains a regular-expression metacharacter (for example [, (, or a trailing backslash) threw an uncaught SyntaxError when 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 a RegExp source without escaping it. This PR escapes the note name before building the RegExp, 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'). In ngOnInit, the queryParamMap subscription runs synchronously via startWith() and calls onParagraphSearch() before the @ViewChildren QueryList (listOfNotebookParagraphComponent) is populated (it is only available after ngAfterViewInit). 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

  • Escape note name before building the clone-name RegExp
  • Guard onParagraphSearch() against an uninitialized @ViewChildren QueryList

What is the Jira issue?

ZEPPELIN-6534

How should this be tested?

  • cd zeppelin-web-angular && npm run lint
  • Create a note named report[2024 (or foo(bar) and click Clone: before the fix the dialog throws SyntaxError and no name is suggested; after the fix it suggests report[2024 1 and clones normally. Clone-name numbering for ordinary names is unchanged (escaping is a no-op when there are no metacharacters).
  • Open any note with the browser devtools console open: before the fix a forEach TypeError is logged on load; after the fix the console is clean.

Questions:

  • Does the license files need to be updated? No
  • Are there breaking changes for older versions? No
  • Does this need documentation? No

kimyenac added 2 commits July 18, 2026 17:54
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant