From 97dfbc880d6261f97e4af44d4d621cdae7ff8adc Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Tue, 26 Feb 2019 09:38:50 -0500 Subject: [PATCH] Now handles urls with spaces in them --- .../com/rarchives/ripme/ripper/AbstractRipper.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java index e708ef68..8e4080ae 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java @@ -237,6 +237,16 @@ public abstract class AbstractRipper * False if failed to download */ protected boolean addURLToDownload(URL url, String prefix, String subdirectory, String referrer, Map cookies, String fileName, String extension, Boolean getFileExtFromMIME) { + // Make sure the url doesn't contain any spaces as that can cause a 400 error when requesting the file + if (url.toExternalForm().contains(" ")) { + // If for some reason the url with all spaces encoded as %20 is malformed print an error + try { + url = new URL(url.toExternalForm().replaceAll(" ", "%20")); + } catch (MalformedURLException e) { + LOGGER.error("Unable to remove spaces from url\nURL: " + url.toExternalForm()); + e.printStackTrace(); + } + } // Don't re-add the url if it was downloaded in a previous rip if (Utils.getConfigBoolean("remember.url_history", true) && !isThisATest()) { if (hasDownloadedURL(url.toExternalForm())) {