1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-27 23:59:59 +02:00

Merge pull request #1242 from cyian-1756/testing

some more checks to avoid downloading invaild urls
This commit is contained in:
cyian-1756
2019-03-16 11:58:25 -05:00
committed by GitHub
3 changed files with 8 additions and 3 deletions

View File

@@ -93,6 +93,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
// We set doc to null here so the while loop below this doesn't fire // We set doc to null here so the while loop below this doesn't fire
doc = null; doc = null;
LOGGER.debug("Adding items from " + this.url + " to queue");
} }
while (doc != null) { while (doc != null) {

View File

@@ -237,6 +237,12 @@ public abstract class AbstractRipper
* False if failed to download * False if failed to download
*/ */
protected boolean addURLToDownload(URL url, String prefix, String subdirectory, String referrer, Map<String, String> cookies, String fileName, String extension, Boolean getFileExtFromMIME) { protected boolean addURLToDownload(URL url, String prefix, String subdirectory, String referrer, Map<String, String> cookies, String fileName, String extension, Boolean getFileExtFromMIME) {
// A common bug is rippers adding urls that are just "http:". This rejects said urls
if (url.toExternalForm().equals("http:") || url.toExternalForm().equals("https:")) {
LOGGER.info(url.toExternalForm() + " is a invalid url amd will be changed");
return false;
}
// Make sure the url doesn't contain any spaces as that can cause a 400 error when requesting the file // 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 (url.toExternalForm().contains(" ")) {
// If for some reason the url with all spaces encoded as %20 is malformed print an error // If for some reason the url with all spaces encoded as %20 is malformed print an error

View File

@@ -1,7 +1,6 @@
package com.rarchives.ripme.ripper; package com.rarchives.ripme.ripper;
import java.io.*; import java.io.*;
import java.lang.reflect.Array;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.URL; import java.net.URL;
@@ -14,13 +13,11 @@ import java.util.ResourceBundle;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import com.rarchives.ripme.ui.MainWindow; import com.rarchives.ripme.ui.MainWindow;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jsoup.HttpStatusException; import org.jsoup.HttpStatusException;
import com.rarchives.ripme.ui.RipStatusMessage.STATUS; import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
import com.rarchives.ripme.utils.Utils; import com.rarchives.ripme.utils.Utils;
import static java.lang.Math.toIntExact;
/** /**
* Thread for downloading files. * Thread for downloading files.
@@ -139,6 +136,7 @@ class DownloadFileThread extends Thread {
int statusCode = huc.getResponseCode(); int statusCode = huc.getResponseCode();
logger.debug("Status code: " + statusCode); logger.debug("Status code: " + statusCode);
// If the server doesn't allow resuming downloads error out
if (statusCode != 206 && observer.tryResumeDownload() && saveAs.exists()) { if (statusCode != 206 && observer.tryResumeDownload() && saveAs.exists()) {
// TODO find a better way to handle servers that don't support resuming downloads then just erroring out // TODO find a better way to handle servers that don't support resuming downloads then just erroring out
throw new IOException(rb.getString("server.doesnt.support.resuming.downloads")); throw new IOException(rb.getString("server.doesnt.support.resuming.downloads"));