Escaping of escape symbols in the MetaData#2445
Conversation
|
I don't understand why unquoting on parse and quoting on writing does not work. As for the StringUtil.quote method, I think, you can edit it directly. If I remember correctly, then its purpose is to ensure that strings are properly encoded for writing them in the bib-file (this applies to all kind of metadata - groups are nothing special). Probably, it would be good to move this method actually to the metadata serializer / parser. |
|
@tobiasdiez You are correct, of course. If we avoid that JabRef writes a single backslash into the file, then everything works fine. My bad, for not getting this immediately. The current PR should be ready for review. |
|
Build is fine expect a fetcher problem -> Merge |
* upstream/master: (67 commits) Medline fix test (#2463) Fix conversion of tilde n (#2459) ctrl+f selects current query while the searchbar is focusd (#2457) incorrect log name of JabRefExecutorService (#2452) unregister DateChangeListener in manual update method (#2450) Escaping of escape symbols in the MetaData (#2445) Fix typo Update gradle from 3.2.1 to 3.3 Use instanceof Remove unused import Avoid ClassCastException in AutoCompleteListener Fix typo in CHANGELOG.md Add support for pages in the format 2:1-2:33 (#2440) L10N-ru update (#2441) Change https to http Update DBLP API endpoint Revert "Chistmas edition colors" Show development information Release v3.8.1 Result of generate-authors.sh ... # Conflicts: # CHANGELOG.md # src/main/java/net/sf/jabref/gui/date/DatePickerButton.java
Fixes #2426 and is ready for review.
Old discussion
Attempts to fix #2426.
Is not yet functional, since the issue goes somewhat deeper and affects LaTeX-encoding things in all MetaData, also groups. The problem is line 64 in MetaDataSerializer:
For every MetaData item, all special characters are quoted, including the quoting symbol (
\). Thus, if there is a\in the MetaData, it is quoted during serialization, resulting in\\, which is read as such and requoted on the next serialization, resulting in\\\\and so on.Unfortunately, unquoting the text during parsing and quoting it again during writing does not help, since a single
\will simply be lost. E.g.: unquoting\"Uwould result in"U, which upon quoting anew would stay"U.The same problem should occur for groups, if I am not mistaken.
I now have the following options to resolve the problem:
StringUtil.quoteto avoid quoting the quoting char (\)I am afraid that changing
StringUtil.quotehas wider implications that I am not aware of., especially relating to groups Hence, there is a need for discussion.