From 678b8108286693e7804d800053e580ae182ab2d2 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 11 Feb 2018 08:24:14 -0500 Subject: [PATCH] AlbumRipper.java now removes bad chars from file names --- .../java/com/rarchives/ripme/ripper/AlbumRipper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java index 124ef163..c06cb4d3 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java @@ -13,6 +13,7 @@ import com.rarchives.ripme.ui.RipStatusMessage; import com.rarchives.ripme.ui.RipStatusMessage.STATUS; import com.rarchives.ripme.utils.Utils; +// Should this file even exist? It does the same thing as abstractHTML ripper /**' * For ripping delicious albums off the interwebz. @@ -50,6 +51,14 @@ public abstract class AlbumRipper extends AbstractRipper { * Queues multiple URLs of single images to download from a single Album URL */ public boolean addURLToDownload(URL url, File saveAs, String referrer, Map cookies) { + // TODO fix this hack + // Sanitize the saveAs file + String fileName = saveAs.getPath(); + if (fileName.indexOf('?') >= 0) { fileName = fileName.substring(0, fileName.indexOf('?')); } + if (fileName.indexOf('&') >= 0) { fileName = fileName.substring(0, fileName.indexOf('&')); } + if (fileName.indexOf(':') >= 0) { fileName = fileName.substring(0, fileName.indexOf(':')); } + if (fileName.indexOf('#') >= 0) { fileName = fileName.substring(0, fileName.indexOf('#')); } + saveAs = new File(fileName); // Only download one file if this is a test. if (super.isThisATest() && (itemsPending.size() > 0 || itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {