diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc4fbe4094..039bc0cba73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue when the preview was out of sync. [#9172](https://github.com/JabRef/jabref/issues/9172) - We fixed an issue where identifier paste couldn't work with Unicode REPLACEMENT CHARACTER. [#11986](https://github.com/JabRef/jabref/issues/11986) - We fixed an issue when click on entry at "Check Integrity" wasn't properly focusing the entry and field. [#11997](https://github.com/JabRef/jabref/issues/11997) +- On saving a non-absolute URI, now a clear error message is shown. [#12186](https://github.com/JabRef/jabref/issues/12186) ### Removed diff --git a/buildres/abbrv.jabref.org b/buildres/abbrv.jabref.org index 0fdf99147a8..1ad9773b13c 160000 --- a/buildres/abbrv.jabref.org +++ b/buildres/abbrv.jabref.org @@ -1 +1 @@ -Subproject commit 0fdf99147a8a5fc8ae7ccd79ad4e0029e736e4a3 +Subproject commit 1ad9773b13c37a919207a0e412c6615f42453e99 diff --git a/src/main/java/org/jabref/logic/util/URLUtil.java b/src/main/java/org/jabref/logic/util/URLUtil.java index fd6317d9d23..49d2c8c970a 100644 --- a/src/main/java/org/jabref/logic/util/URLUtil.java +++ b/src/main/java/org/jabref/logic/util/URLUtil.java @@ -89,7 +89,11 @@ public static boolean isURL(String url) { * @throws MalformedURLException if the URL is malformed and cannot be converted to a {@link URL}. */ public static URL create(String url) throws MalformedURLException { - return createUri(url).toURL(); + URI uri = createUri(url); + if (!uri.isAbsolute()) { + throw new MalformedURLException("URI is not absolute: " + url); + } + return uri.toURL(); } /** diff --git a/src/main/resources/csl-locales b/src/main/resources/csl-locales index 96d704de2fc..4753e3a9aca 160000 --- a/src/main/resources/csl-locales +++ b/src/main/resources/csl-locales @@ -1 +1 @@ -Subproject commit 96d704de2fc7b930ae4a0ec4686a7143bb4a0d33 +Subproject commit 4753e3a9aca4b806ac0e3036ed727d47bf8f678e diff --git a/src/main/resources/csl-styles b/src/main/resources/csl-styles index b90b81a58b1..1931353cec3 160000 --- a/src/main/resources/csl-styles +++ b/src/main/resources/csl-styles @@ -1 +1 @@ -Subproject commit b90b81a58b1a260423608f3868a6613cc6efe431 +Subproject commit 1931353cec337cb62ef3f9049a78e4f91a3834b9 diff --git a/src/test/java/org/jabref/logic/net/URLUtilTest.java b/src/test/java/org/jabref/logic/net/URLUtilTest.java index 7de7b641fc5..b33a00e0557 100644 --- a/src/test/java/org/jabref/logic/net/URLUtilTest.java +++ b/src/test/java/org/jabref/logic/net/URLUtilTest.java @@ -1,13 +1,18 @@ package org.jabref.logic.net; +import java.net.MalformedURLException; import java.net.URI; +import java.net.URL; import org.jabref.logic.util.URLUtil; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; class URLUtilTest { @@ -87,4 +92,22 @@ void createUriShouldHandlePipeCharacter() { URI uri = URLUtil.createUri(input); assertEquals("http://example.com/test%7Cfile", uri.toString()); } + + @Test + void createWithAbsoluteURL() { + String absoluteUrl = "http://www.example.com"; + assertDoesNotThrow(() -> { + URL url = URLUtil.create(absoluteUrl); + assertNotNull(url); + assertEquals(absoluteUrl, url.toString()); + }, "MalformedURLException should not be thrown for an absolute URL"); + } + + @Test + void createWithNonAbsoluteURL() { + String nonAbsoluteUrl = "www.example.com"; + assertThrows(MalformedURLException.class, () -> { + URLUtil.create(nonAbsoluteUrl); + }); + } }