diff --git a/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java index 58fc3547ec8..c2c1ec07401 100644 --- a/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java +++ b/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java @@ -71,8 +71,6 @@ public static void openExternalViewer(MetaData metaData, String link, String fie } else if ("eprint".equals(fieldName)) { fieldName = "url"; - link = URLUtil.sanitizeUrl(link); - // Check to see if link field already contains a well formated URL if (!link.startsWith("http://")) { link = Util.ARXIV_LOOKUP_PREFIX + link; @@ -427,7 +425,6 @@ private static void openFolderAndSelectFileOnWindows(String link) throws IOExcep * @throws IOException */ public static void openBrowser(String url) throws IOException { - url = URLUtil.sanitizeUrl(url); ExternalFileType fileType = Globals.prefs.getExternalFileTypeByExt("html"); openExternalFilePlatformIndependent(fileType, url); } diff --git a/src/main/java/net/sf/jabref/logic/util/io/URLUtil.java b/src/main/java/net/sf/jabref/logic/util/io/URLUtil.java index 5f44631973f..30be4ea7f05 100644 --- a/src/main/java/net/sf/jabref/logic/util/io/URLUtil.java +++ b/src/main/java/net/sf/jabref/logic/util/io/URLUtil.java @@ -79,44 +79,4 @@ public static String cleanGoogleSearchURL(String url) { } } - /** - * Make sure an URL is "portable", in that it doesn't contain bad characters that break the open command in some - * OSes. A call to this method will also remove \\url{} enclosings. - * - * It does: - * - trim whitespace - * - remove Latex \\url{} tags - * - * @param link the URL to sanitize. - * @return the sanitized URL - */ - public static String sanitizeUrl(String link) { - // remove whitespace - link = link.trim(); - - // Remove \\url{} - if (link.startsWith("\\url{") && link.endsWith("}")) { - link = link.substring(5, link.length() - 1); - } - - // FIXME: everything below is really flawed atm - link = link.replaceAll("\\+", "%2B"); - - try { - link = URLDecoder.decode(link, StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException ignored) { - // Ignored - } - - /** - * Fix for: [ 1574773 ] sanitizeUrl() breaks ftp:// and file:/// - * - * http://sourceforge.net/tracker/index.php?func=detail&aid=1574773&group_id=92314&atid=600306 - */ - try { - return new URI(null, link, null).toASCIIString(); - } catch (URISyntaxException e) { - return link; - } - } } diff --git a/src/test/java/net/sf/jabref/logic/util/io/URLUtilTest.java b/src/test/java/net/sf/jabref/logic/util/io/URLUtilTest.java index cbb4f693450..d1214ed280e 100644 --- a/src/test/java/net/sf/jabref/logic/util/io/URLUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/util/io/URLUtilTest.java @@ -59,19 +59,4 @@ public void cleanGoogleSearchURL() throws Exception { URLUtil.cleanGoogleSearchURL("https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=ftp%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") ); } - - @Test - public void testSanitizeUrl() { - Assert.assertEquals("http://www.vg.no", URLUtil.sanitizeUrl("http://www.vg.no")); - Assert.assertEquals("http://www.vg.no/fil%20e.html", URLUtil.sanitizeUrl("http://www.vg.no/fil e.html")); - Assert.assertEquals("http://www.vg.no/fil%20e.html", URLUtil.sanitizeUrl("http://www.vg.no/fil%20e.html")); - Assert.assertEquals("www.vg.no/fil%20e.html", URLUtil.sanitizeUrl("www.vg.no/fil%20e.html")); - Assert.assertEquals("www.vg.no/fil%20e.html", URLUtil.sanitizeUrl("\\url{www.vg.no/fil%20e.html}")); - Assert.assertEquals("ftp://www.vg.no", URLUtil.sanitizeUrl("ftp://www.vg.no")); - Assert.assertEquals("file://doof.txt", URLUtil.sanitizeUrl("file://doof.txt")); - Assert.assertEquals("file:///", URLUtil.sanitizeUrl("file:///")); - Assert.assertEquals("/src/doof.txt", URLUtil.sanitizeUrl("/src/doof.txt")); - Assert.assertEquals("/", URLUtil.sanitizeUrl("/")); - Assert.assertEquals("/home/user/example.txt", URLUtil.sanitizeUrl("/home/user/example.txt")); - } }