diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java index 5bd39dcd..f8adce98 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java @@ -183,6 +183,7 @@ public abstract class AbstractRipper if (!subdirectory.equals("")) { subdirectory = File.separator + subdirectory; } + prefix = Utils.filesystemSanitized(prefix); saveFileAs = new File( workingDir.getCanonicalPath() + subdirectory diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java index 657c6ee2..c085059c 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/InstagramRipper.java @@ -144,6 +144,7 @@ public class InstagramRipper extends AbstractHTMLRipper { Long epoch = data.getLong("date"); Instant instant = Instant.ofEpochSecond(epoch); String image_date = DateTimeFormatter.ofPattern("yyyy_MM_dd_hh:mm_").format(ZonedDateTime.ofInstant(instant, ZoneOffset.UTC)); + try { if (!data.getBoolean("is_video")) { if (imageURLs.size() == 0) { @@ -158,8 +159,8 @@ public class InstagramRipper extends AbstractHTMLRipper { } catch (MalformedURLException e) { return imageURLs; } - nextPageID = data.getString("id"); + nextPageID = data.getString("id"); if (isThisATest()) { break; diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index 28d42f20..d9f8bf9e 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -355,6 +355,11 @@ public class Utils { + path.substring(path.length() - SHORTENED_PATH_LENGTH); } + public static String filesystemSanitized(String text) { + text = text.replaceAll("[^a-zA-Z0-9.-]", "_"); + return text; + } + public static String filesystemSafe(String text) { text = text.replaceAll("[^a-zA-Z0-9.-]", "_") .replaceAll("__", "_")