Implement escaping of keyword delimiters#14637
Merged
Merged
Conversation
…eywordListTest to match new formatting
calixtus
reviewed
Dec 17, 2025
calixtus
reviewed
Dec 17, 2025
koppor
previously requested changes
Dec 18, 2025
BOgdAnSAM-sudo
commented
Dec 18, 2025
Comment on lines
+159
to
+177
| @ParameterizedTest | ||
| @MethodSource("parseKeywordWithEscapedDelimiterDoesNotSplitKeyword") | ||
| void afterFirstParsingNoChangesShouldBeDoneToKeywords(String input, KeywordList expected) { | ||
| char delimiter = ','; | ||
| KeywordList firstParse = KeywordList.parse(input, delimiter); | ||
| String serialized = KeywordList.serialize(firstParse.stream().toList(), delimiter); | ||
| KeywordList secondParse = KeywordList.parse(serialized, delimiter); | ||
| assertEquals(expected, secondParse); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("serializeKeywordWithNonEscapedDelimiterJoinsKeywordsCorrectly") | ||
| void afterFirstSerializeNoChangesShouldBeDoneToKeywords(List<Keyword> input, String expected) { | ||
| char delimiter = ','; | ||
| String firstSerialize = KeywordList.serialize(input, delimiter); | ||
| KeywordList parsed = KeywordList.parse(firstSerialize, delimiter); | ||
| String secondSerialize = KeywordList.serialize(parsed.stream().toList(), delimiter); | ||
| assertEquals(expected, secondSerialize); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
I divided afterFirstSerializeNoChangesShouldBeDoneToKeywords into two tests for better readability, but they still relly on MethodSource from other methods, is it okay to specify methodSource method in this case?
Member
There was a problem hiding this comment.
I say yes, to keep moving forward.
Contributor
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
Resolve CHANGELOG conflicts
calixtus
approved these changes
Dec 22, 2025
Member
|
Thanks for your effort. Putting into merge queue. |
6 tasks
6 tasks
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.
Closes #12810
Implemented escaping of delimeters in keywords in KeywordList#parse using (#12888 (comment)) and reworked KeywordList#serialize to match new logic. Also added tests for new functionality
Steps to test
keywords = {Keyword \> Keyword,Keyword > Keyword,KeywordOne\,KeywordTwo, KeywordOne,KeywordTwo,keyword\\,keyword}After executing this steps we can see that in Keywords field keywords are formatted in readable, 'nice' strings and in "BibTeX sorce" keywords have good unique serialization.
Important note:
When I was testing the GUI, I noticed that it isn't possible to enter a keyword with an escaped delimiter by hand, only paste the whole keyword.
This happens due to logic in org/jabref/gui/fieldeditors/KeywordsEditor; it checks every symbol that is typed into the field, and if this symbol is a delimiter, it automatically commits the new keyword.
I don't know if I should change the logic of KeywordsEditor because it exceeds the scope of this Issue.
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)