From e69c84f2b950b829416b8b7a3c07a95c9f25fa44 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 3 Jan 2022 21:17:18 +0100 Subject: [PATCH] Change default behavior of resolve bibtex strings Fixes #7010 Fixes #7012 Fixes #8303 --- CHANGELOG.md | 2 ++ .../jabref/migrations/PreferencesMigrations.java | 13 +++++++++++++ .../org/jabref/preferences/JabRefPreferences.java | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ac2abf243d..36285d26e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,11 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed - We integrated the external file types dialog directly inside the preferences. [#8341](https://github.com/JabRef/jabref/pull/8341) +- We disabled BibTeX String resolving by default for the fields `url`, `abstract`, `note`, `comment`, `doi` and `file` to keep #-chars [#7010](https://github.com/JabRef/jabref/issues/7010), [#7102](https://github.com/JabRef/jabref/issues/7012), [#8303]((https://github.com/JabRef/jabref/issues/8303)) ### Fixed +- We fixed an issue where #-chars in certain fields would be interpreted as BibTeX-Strings [#7010](https://github.com/JabRef/jabref/issues/7010), [#7102](https://github.com/JabRef/jabref/issues/7012), [#8303]((https://github.com/JabRef/jabref/issues/8303)) - We fixed an issue where clicking on "Accept changes" in the merge dialog would lead to an exception [forum#2418](https://discourse.jabref.org/t/the-library-has-been-modified-by-another-program/2418/8) - We fixed an issue where clicking on headings in the entry preview could lead to an exception. [#8292](https://github.com/JabRef/jabref/issues/8292) - We fixed an issue where IntegrityCheck used the system's character encoding instead of the one set by the library or in preferences [#8022](https://github.com/JabRef/jabref/issues/8022) diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 6ff137d6d0f..cc9d34d6a76 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -55,6 +55,7 @@ public static void runMigrations() { upgradeColumnPreferences(Globals.prefs); restoreVariablesForBackwardCompatibility(Globals.prefs); upgradePreviewStyleAllowMarkdown(Globals.prefs); + migrateDoNotResolveFields(Globals.prefs); } /** @@ -290,6 +291,18 @@ private static void addCrossRefRelatedFieldsForAutoComplete(JabRefPreferences pr prefs.putStringList(JabRefPreferences.AUTOCOMPLETER_COMPLETE_FIELDS, new ArrayList<>(keys)); } + private static void migrateDoNotResolveFields(JabRefPreferences prefs) { + Set keys = new LinkedHashSet<>(prefs.getStringList(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR)); + keys.add("url"); + keys.add("abstract"); + keys.add("note"); + keys.add("comment"); + keys.add("doi"); + keys.add("eprint"); + keys.add("file"); + prefs.putStringList(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR, new ArrayList<>(keys)); + } + private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences oldPatternPrefs) throws BackingStoreException { LOGGER.info("Found old Bibtex Key patterns which will be migrated to new version."); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index b596c4b377e..ba4906cea74 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -225,7 +225,7 @@ public class JabRefPreferences implements PreferencesService { public static final String WARN_ABOUT_DUPLICATES_IN_INSPECTION = "warnAboutDuplicatesInInspection"; public static final String NON_WRAPPABLE_FIELDS = "nonWrappableFields"; - public static final String RESOLVE_STRINGS_ALL_FIELDS = "resolveStringsAllFields"; + public static final String RESOLVE_STRINGS_ALL_FIELDS = "resolveStringsAllFields55"; public static final String DO_NOT_RESOLVE_STRINGS_FOR = "doNotResolveStringsFor"; public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; public static final String CUSTOM_EXPORT_FORMAT = "customExportFormat"; @@ -631,8 +631,8 @@ private JabRefPreferences() { defaults.put(CONFIRM_DELETE, Boolean.TRUE); defaults.put(DEFAULT_CITATION_KEY_PATTERN, "[auth][year]"); defaults.put(UNWANTED_CITATION_KEY_CHARACTERS, "-`สน:!;?^+"); - defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, StandardField.URL.getName()); - defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); + defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, "url;abstract;note;comment;doi;eprint;file"); + defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.TRUE); defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file;isbn;issn"); defaults.put(WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE); defaults.put(ADD_CREATION_DATE, Boolean.FALSE);