-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for escape syntax to enable literal placeholders #11904
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #11904 +/- ##
===========================================
- Coverage 63.92% 63.89% -0.03%
===========================================
Files 369 369
Lines 38920 38925 +5
===========================================
- Hits 24878 24871 -7
- Misses 14042 14054 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -49,6 +49,8 @@ This section contains full details on advanced features available in KeePassXC. | |||
|{DB_DIR} |Absolute directory path of database file | |||
|=== | |||
|
|||
NOTE: You can insert literal placeholder strings by escaping the beginning and ending curly braces. For example, to insert the string `{USERNAME}`, you would type `++\{USERNAME\}++`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the ++ for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It allows printing the \{ and \} in the code block. Without that it doesn't print
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure about that? At least here it seems to work, but maybe that's an ascii doc quirk. \{USERNAME\}
Edit: I see, seems to be needed indeed, though double-\ might work as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double \ prints a double \ . Quirky
// Short circuit if we have escaped the placeholder brackets | ||
if (str.startsWith("\\{") && str.endsWith("\\}")) { | ||
// Replace the escaped brackets with actuals and move on | ||
auto ret = str; | ||
ret.replace(0, 2, "{"); | ||
ret.replace(ret.size() - 2, 2, "}"); | ||
return ret; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very brittle escaping mechanism. Either we need a proper state machine for parsing the syntax or this should at least be part of the regex, e.g. as negative lookbehinds/lookaheads.
e09cf0b
to
1b1c2b0
Compare
Testing strategy
Added a test case, all existing ones pass, this is a minimal change that would not break existing placeholder syntax.
Type of change