diff --git a/CHANGELOG.md b/CHANGELOG.md index 05326db0008..d33d741c353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where "Copy DOI url" in the right-click menu of the Entry List would just copy the DOI and not the DOI url. [#8389](https://github.com/JabRef/jabref/issues/8389) - We fixed an issue where opening the console from the drop-down menu would cause an exception. [#8466](https://github.com/JabRef/jabref/issues/8466) - We fixed an issue where pasting a URL was replacing + signs by spaces making the URL unreachable. [#8448](https://github.com/JabRef/jabref/issues/8448) +- We fixed an issue where creating subsidiary files from aux files created with some versions of biblatex would produce incorrect results. [#8513](https://github.com/JabRef/jabref/issues/8513) ### Removed diff --git a/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java b/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java index 8e391226575..68c80974aa4 100644 --- a/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java +++ b/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java @@ -32,7 +32,7 @@ public class DefaultAuxParser implements AuxParser { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAuxParser.class); - private static final Pattern CITE_PATTERN = Pattern.compile("\\\\(citation|abx@aux@cite)\\{(.+)\\}"); + private static final Pattern CITE_PATTERN = Pattern.compile("\\\\(citation|abx@aux@cite)(\\{\\d+\\})?\\{(?.+)\\}"); private static final Pattern INPUT_PATTERN = Pattern.compile("\\\\@input\\{(.+)\\}"); private final BibDatabase masterDatabase; @@ -108,7 +108,7 @@ private void matchCitation(AuxParserResult result, String line) { Matcher citeMatch = CITE_PATTERN.matcher(line); while (citeMatch.find()) { - String keyString = citeMatch.group(2); + String keyString = citeMatch.group("citationkey"); String[] keys = keyString.split(","); for (String key : keys) { diff --git a/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java b/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java index a85c8468060..781a0ed6288 100644 --- a/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java +++ b/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java @@ -6,7 +6,7 @@ /** * Searches web resources for bibliographic information based on a {@link BibEntry}. - * Useful to complete an existing entry with fetched information. + * Useful to complete an existing entry with fetched information. * May return multiple search hits. */ public interface EntryBasedFetcher extends WebFetcher { diff --git a/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java b/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java index 0238ef6b89a..62caee59199 100644 --- a/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java +++ b/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java @@ -6,6 +6,7 @@ /** * Searches web resources for bibliographic information based on an identifier. + * Examples are ISBN numbers and DOIs. */ public interface IdBasedFetcher extends WebFetcher { diff --git a/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java b/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java index 8e3e3d75533..34858548f7e 100644 --- a/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java +++ b/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java @@ -15,6 +15,9 @@ /** * Searches web resources for bibliographic information based on a free-text query. * May return multiple search hits. + *

+ * This interface is used for web resources which directly return BibTeX data ({@link BibEntry}) + *

*/ public interface SearchBasedFetcher extends WebFetcher { diff --git a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java index 9aadba697b9..808b1b57988 100644 --- a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java @@ -13,12 +13,25 @@ import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; /** - * Provides a convenient interface for search-based fetcher, which follow the usual three-step procedure: + * Provides a convenient interface for search-based fetcher, which follows the usual three-step procedure: *
    *
  1. Open a URL based on the search query
  2. *
  3. Parse the response to get a list of {@link BibEntry}
  4. *
  5. Post-process fetched entries
  6. *
+ *

+ * This interface is used for web resources which do NOT provide BibTeX data (@link {@link BibEntry)}. + * JabRef's infrastructure to convert arbitrary input data to BibTeX is {@link Parser}. + *

+ *

+ * This interface inherits {@link SearchBasedFetcher}, because the methods performSearch have to be provided by both. + * As non-BibTeX web fetcher one could do "magic" stuff without this helper interface and directly use {@link WebFetcher}, but this is more work. + *

+ *

+ * Note that this interface "should" be an abstract class. + * However, Java does not support multi inheritance with classes (but with interfaces). + * We need multi inheritance, because a fetcher might implement multiple query types (such as id fetching {@link IdBasedFetcher)}, complete entry {@link EntryBasedFetcher}, and search-based fetcher (this class). + *

*/ public interface SearchBasedParserFetcher extends SearchBasedFetcher { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java b/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java index 0e46e834134..9a345ec595a 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java @@ -71,8 +71,8 @@ public List parseDoiSearchPage(InputStream stream) throws ParseException Elements doiHrefs = doc.select("div.issue-item__content-right > h5 > span > a"); for (Element elem : doiHrefs) { - String fullSegement = elem.attr("href"); - String doi = fullSegement.substring(fullSegement.indexOf("10")); + String fullSegment = elem.attr("href"); + String doi = fullSegment.substring(fullSegment.indexOf("10")); doiList.add(doi); } } catch (IOException ex) { diff --git a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java index e171fb56ccd..7b1ecb29e4f 100644 --- a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java +++ b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java @@ -64,6 +64,33 @@ void testNormal() throws URISyntaxException, IOException { } } + @Test + void testTwoArgMacro() throws URISyntaxException, IOException { + // Result should be identical to that of testNormal + + InputStream originalStream = AuxParserTest.class.getResourceAsStream("origin.bib"); + Path auxFile = Path.of(AuxParserTest.class.getResource("papertwoargmacro.aux").toURI()); + try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) { + ParserResult result = new BibtexParser(importFormatPreferences, new DummyFileUpdateMonitor()).parse(originalReader); + + AuxParser auxParser = new DefaultAuxParser(result.getDatabase()); + AuxParserResult auxResult = auxParser.parse(auxFile); + + assertTrue(auxResult.getGeneratedBibDatabase().hasEntries()); + assertEquals(0, auxResult.getUnresolvedKeysCount()); + BibDatabase newDB = auxResult.getGeneratedBibDatabase(); + List newEntries = newDB.getEntries(); + assertEquals(2, newEntries.size()); + assertTrue(newEntries.get(0).hasChanged()); + assertTrue(newEntries.get(1).hasChanged()); + assertEquals(2, auxResult.getResolvedKeysCount()); + assertEquals(2, auxResult.getFoundKeysInAux()); + assertEquals(auxResult.getFoundKeysInAux() + auxResult.getCrossRefEntriesCount(), + auxResult.getResolvedKeysCount() + auxResult.getUnresolvedKeysCount()); + assertEquals(0, auxResult.getCrossRefEntriesCount()); + } + } + @Test void testNotAllFound() throws URISyntaxException, IOException { InputStream originalStream = AuxParserTest.class.getResourceAsStream("origin.bib"); diff --git a/src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux b/src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux new file mode 100644 index 00000000000..347f3f78480 --- /dev/null +++ b/src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux @@ -0,0 +1,8 @@ +\relax +\abx@aux@cite{0}{Darwin1888} +\abx@aux@cite{0}{Einstein1920} +\bibstyle{plain} +\bibdata{origin} +\bibcite{Darwin1888}{1} +\bibcite{Einstein1920}{2} +\@writefile{toc}{\contentsline {section}{\numberline {1}}{1}}