Repository navigation
fix(#176): escape \S in the special variable regex - #181
Open
VanshajPoonia wants to merge 1 commit into
Open
VanshajPoonia wants to merge 1 commit into
VanshajPoonia wants to merge 1 commit into
Conversation
The pattern is built inside a template literal, where \S collapses to a literal S. The character class then matched anything except S and a newline, so a line such as `my_template_title: text` was taken for `template_title`, and that line got quoted instead of the real one.
VanshajPoonia
marked this pull request as ready for review
October 12, 2026 17:13
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.
Fixes #176
What
Escape the backslash in the pattern
wrapInQuotesuses to find special variable lines, so the regex receives\Sas intended.Why
The pattern is built in a template literal, where
\Scollapses to a literalS. The compiled pattern was^[^S\n]*template_title[^S\n]*:.*, so "optional whitespace" became "anything exceptS". A variable such asmy_template_titlewas matched astemplate_title: that line got quoted, and the realtemplate_titleline was left unquoted.On master this template fails with "template_title should be a string, found object".
The
eslint-disable-next-line no-useless-escapeabove the line was silencing the warning that pointed at this, so it is removed.Testing
devbranch, with the plugin loaded through--dev-plugins: the template above now creates a note titled with the typed value. On master, the same steps show the error quoted above.AI Assistance Disclosure
I used an AI coding assistant to investigate the issue, write the fix and the test, and draft this description. The tests and lint pass locally, and the fix was checked end to end in a Joplin desktop dev build.