Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- After importing, now all imported entries are marked. [#13535](https://github.com/JabRef/jabref/pull/13535)
- The URL integrity check now checks the complete URL syntax. [#14370](https://github.com/JabRef/jabref/pull/14370)
- <kbd>Tab</kbd> in the last text field of a tab moves the focus to the next tab in the entry editor. [#11937](https://github.com/JabRef/jabref/issues/11937)
- When pasting invalid BibTeX data, the content is now pasted as `@Misc` with the raw data in the `note` field. [#14520](https://github.com/JabRef/jabref/pull/14520)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but in the code it's comment

- We changed fixed-value ComboBoxes to SearchableComboBox for better usability. [#14083](https://github.com/JabRef/jabref/issues/14083)

### Fixed
Expand Down
7 changes: 6 additions & 1 deletion jabgui/src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
import org.jabref.model.entry.event.EntriesEventSource;
import org.jabref.model.entry.event.FieldChangedEvent;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.groups.GroupTreeNode;
import org.jabref.model.search.query.SearchQuery;
import org.jabref.model.util.FileUpdateMonitor;
Expand Down Expand Up @@ -894,7 +896,10 @@ private List<BibEntry> handleNonBibTeXStringData(String data) {
} else {
dialogService.showErrorDialogAndWait(exception);
}
return List.of();
BibEntry fallBack = new BibEntry(StandardEntryType.Misc)
.withField(StandardField.COMMENT, data)
.withChanged(true);
return List.of(fallBack);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

import com.airhacks.afterburner.injection.Injector;
import com.google.common.annotations.VisibleForTesting;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -391,15 +392,20 @@ private void generateKeys(List<BibEntry> entries) {
entries.forEach(keyGenerator::generateAndSetKey);
}

public List<BibEntry> handleBibTeXData(String entries) {
public @NonNull List<@NonNull BibEntry> handleBibTeXData(@NonNull String entries) {
if (!entries.contains("@")) {
LOGGER.debug("Seems not to be BibTeX data: {}", entries);
return List.of();
}
BibtexParser parser = new BibtexParser(preferences.getImportFormatPreferences(), fileUpdateMonitor);
try {
List<BibEntry> result = parser.parseEntries(new ByteArrayInputStream(entries.getBytes(StandardCharsets.UTF_8)));
Collection<BibtexString> stringConstants = parser.getStringValues();
importStringConstantsWithDuplicateCheck(stringConstants);
return result;
} catch (ParseException ex) {
LOGGER.error("Could not paste", ex);
LOGGER.info("Data could not be interpreted as Bib(La)TeX", ex);
dialogService.notify(Localization.lang("Failed to parse Bib(La)TeX: %0", ex.getLocalizedMessage()));
return List.of();
}
}
Expand Down