Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into dependabot/gradle/c…
Browse files Browse the repository at this point in the history
…om.puppycrawl.tools-checkstyle-10.0

* upstream/main:
  Fix online link detection in entry editor (#8514)
  Add some JavaDoc to Fetchers
  Support two argument form of \abx@aux@cite macro in DefaultAuxParser (#8549)
  Bump guava from 31.0.1-jre to 31.1-jre (#8543)
  Bump org.beryx.jlink from 2.24.4 to 2.25.0 (#8548)
  Bump postgresql from 42.3.2 to 42.3.3 (#8546)
  Bump richtextfx from 0.10.7 to 0.10.9 (#8547)
  Bump archunit-junit5-engine from 0.22.0 to 0.23.1 (#8545)
  Bump actions/checkout from 2 to 3 (#8542)
  • Loading branch information
Siedlerchr committed Mar 7, 2022
2 parents bae93bb + 0c439de commit dd798df
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
name: Create installer and portable version for ${{ matrix.displayName }}
steps:
- name: Fetch all history for all tags and branches
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
env:
BUILDJABREFPRIVATEKEY: ${{ secrets.buildJabRefPrivateKey }}
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Install GitVersion
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine dates
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/refresh-csl-subtrees.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
if: github.repository == 'JabRef/jabref'
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/refresh-journal-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Fetch all history for all tags and branches
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: main
persist-credentials: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
env:
SNAPCRAFT_LOGIN_FILE: ${{ secrets.SNAPCRAFT_LOGIN_FILE }}
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
# The image relies on https://builds.jabref.org/master/JabRef-5.0-portable_linux.tar.gz^
# See snap/snapcraft.yml for details
- name: Run snapcraft build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-fetchers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand All @@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
env:
SNAPCRAFT_LOGIN_FILE: ${{ secrets.CODECOV_TOKEN }}
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand All @@ -174,5 +174,5 @@ jobs:
name: "Validate Gradle Wrapper"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
2 changes: 1 addition & 1 deletion .github/workflows/update-gradle-wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Update Gradle Wrapper
uses: gradle-update/update-gradle-wrapper-action@v1
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where online links in the file field were not detected correctly and could produce an exception [#8150](https://github.com/JabRef/jabref/issues/8510)
- We fixed an issue where an exception could occur when saving the preferences [#7614](https://github.com/JabRef/jabref/issues/7614)
- 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

Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {

id 'org.openjfx.javafxplugin' version '0.0.12'

id 'org.beryx.jlink' version '2.24.4'
id 'org.beryx.jlink' version '2.25.0'

// nicer test outputs during running and completion
// Homepage: https://github.com/radarsh/gradle-test-logger-plugin
Expand Down Expand Up @@ -147,14 +147,14 @@ dependencies {

implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.5'

implementation 'org.postgresql:postgresql:42.3.2'
implementation 'org.postgresql:postgresql:42.3.3'

implementation ('com.oracle.ojdbc:ojdbc10:19.3.0.0') {
// causing module issues
exclude module: 'oraclepki'
}

implementation ('com.google.guava:guava:31.0.1-jre') {
implementation ('com.google.guava:guava:31.1-jre') {
// TODO: Remove this as soon as https://github.com/google/guava/issues/2960 is fixed
exclude module: "jsr305"
}
Expand All @@ -168,7 +168,7 @@ dependencies {
implementation 'de.saxsys:mvvmfx:1.8.0'
implementation 'com.tobiasdiez:easybind:2.2'
implementation 'org.fxmisc.flowless:flowless:0.6.8'
implementation 'org.fxmisc.richtext:richtextfx:0.10.7'
implementation 'org.fxmisc.richtext:richtextfx:0.10.9'
implementation group: 'org.glassfish.hk2.external', name: 'jakarta.inject', version: '2.6.1'
implementation 'com.jfoenix:jfoenix:9.0.10'
implementation 'org.controlsfx:controlsfx:11.1.1'
Expand Down Expand Up @@ -211,7 +211,7 @@ dependencies {
testImplementation 'org.mockito:mockito-core:4.3.1'
testImplementation 'org.xmlunit:xmlunit-core:2.9.0'
testImplementation 'org.xmlunit:xmlunit-matchers:2.9.0'
testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:0.22.0'
testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:0.23.1'
testImplementation 'com.tngtech.archunit:archunit-junit5-api:0.23.1'
testImplementation "org.testfx:testfx-core:4.0.17-alpha-SNAPSHOT"
testImplementation "org.testfx:testfx-junit5:4.0.17-alpha-SNAPSHOT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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+\\})?\\{(?<citationkey>.+)\\}");
private static final Pattern INPUT_PATTERN = Pattern.compile("\\\\@input\\{(.+)\\}");

private final BibDatabase masterDatabase;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <emph>complete</emph> an existing entry with fetched information.
* May return multiple search hits.
*/
public interface EntryBasedFetcher extends WebFetcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
/**
* Searches web resources for bibliographic information based on a free-text query.
* May return multiple search hits.
* <p>
* This interface is used for web resources which directly return BibTeX data ({@link BibEntry})
* </p>
*/
public interface SearchBasedFetcher extends WebFetcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <ol>
* <li>Open a URL based on the search query</li>
* <li>Parse the response to get a list of {@link BibEntry}</li>
* <li>Post-process fetched entries</li>
* </ol>
* <p>
* This interface is used for web resources which do NOT provide BibTeX data {@link BibEntry}.
* JabRef's infrastructure to convert arbitrary input data to BibTeX is {@link Parser}.
* </p>
* <p>
* This interface inherits {@link SearchBasedFetcher}, because the methods <code>performSearch</code> 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.
* </p>
* <p>
* 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).
* </p>
*/
public interface SearchBasedParserFetcher extends SearchBasedFetcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public List<String> 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) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/model/entry/LinkedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Pattern;

import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
Expand All @@ -26,6 +27,9 @@
*/
public class LinkedFile implements Serializable {

private static final String REGEX_URL = "^((?:https?\\:\\/\\/|www\\.)(?:[-a-z0-9]+\\.)*[-a-z0-9]+.*)";
private static final Pattern URL_PATTERN = Pattern.compile(REGEX_URL);

private static final LinkedFile NULL_OBJECT = new LinkedFile("", Path.of(""), "");

// We have to mark these properties as transient because they can't be serialized directly
Expand Down Expand Up @@ -145,7 +149,7 @@ private void readObject(ObjectInputStream in) throws IOException {
*/
public static boolean isOnlineLink(String toCheck) {
String normalizedFilePath = toCheck.trim().toLowerCase();
return normalizedFilePath.startsWith("http://") || normalizedFilePath.startsWith("https://") || normalizedFilePath.contains("www.");
return URL_PATTERN.matcher(normalizedFilePath).matches();
}

@Override
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/org/jabref/logic/auxparser/AuxParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<BibEntry> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,34 @@ private static Stream<Arguments> stringsToParseTestData() throws Exception {
"desc:file.pdf:PDF:asdf"
),

// www inside filename
Arguments.of(
Collections.singletonList(new LinkedFile("", Path.of("/home/www.google.de.pdf"), "")),
":/home/www.google.de.pdf"
),

// url
Arguments.of(
Collections.singletonList(new LinkedFile(new URL("https://books.google.de/"), "")),
"https://books.google.de/"
),

// url with www
Arguments.of(
Collections.singletonList(new LinkedFile(new URL("https://www.google.de/"), "")),
"https://www.google.de/"
),

// url as file
Arguments.of(
Collections.singletonList(new LinkedFile("", new URL("http://ceur-ws.org/Vol-438"), "URL")),
":http\\://ceur-ws.org/Vol-438:URL"
)
),
// url as file with desc
Arguments.of(
Collections.singletonList(new LinkedFile("desc", new URL("http://ceur-ws.org/Vol-438"), "URL")),
"desc:http\\://ceur-ws.org/Vol-438:URL"
)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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}}

0 comments on commit dd798df

Please sign in to comment.