mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-16 19:04:05 +02:00
sanitizeURL can throw URISyntaxException.
This commit is contained in:
@@ -73,7 +73,7 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
protected boolean hasDescriptionSupport() {
|
protected boolean hasDescriptionSupport() {
|
||||||
|
@@ -172,7 +172,11 @@ public abstract class AbstractRipper
|
|||||||
if (!canRip(url)) {
|
if (!canRip(url)) {
|
||||||
throw new MalformedURLException("Unable to rip url: " + url);
|
throw new MalformedURLException("Unable to rip url: " + url);
|
||||||
}
|
}
|
||||||
this.url = sanitizeURL(url);
|
try {
|
||||||
|
this.url = sanitizeURL(url);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new MalformedURLException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -14,7 +14,7 @@ import java.net.URL;
|
|||||||
interface RipperInterface {
|
interface RipperInterface {
|
||||||
void rip() throws IOException, URISyntaxException;
|
void rip() throws IOException, URISyntaxException;
|
||||||
boolean canRip(URL url);
|
boolean canRip(URL url);
|
||||||
URL sanitizeURL(URL url) throws MalformedURLException;
|
URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException;
|
||||||
void setWorkingDir(URL url) throws IOException;
|
void setWorkingDir(URL url) throws IOException;
|
||||||
String getHost();
|
String getHost();
|
||||||
String getGID(URL url) throws MalformedURLException;
|
String getGID(URL url) throws MalformedURLException;
|
||||||
|
@@ -2,6 +2,8 @@ package com.rarchives.ripme.ripper.rippers;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -62,7 +64,7 @@ public class FlickrRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||||
String sUrl = url.toExternalForm();
|
String sUrl = url.toExternalForm();
|
||||||
// Strip out https
|
// Strip out https
|
||||||
sUrl = sUrl.replace("https://secure.flickr.com", "http://www.flickr.com");
|
sUrl = sUrl.replace("https://secure.flickr.com", "http://www.flickr.com");
|
||||||
@@ -73,7 +75,7 @@ public class FlickrRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
sUrl += "pool";
|
sUrl += "pool";
|
||||||
}
|
}
|
||||||
return new URL(sUrl);
|
return new URI(sUrl).toURL();
|
||||||
}
|
}
|
||||||
// FLickr is one of those sites what includes a api key in sites javascript
|
// FLickr is one of those sites what includes a api key in sites javascript
|
||||||
// TODO let the user provide their own api key
|
// TODO let the user provide their own api key
|
||||||
|
@@ -9,6 +9,7 @@ import org.jsoup.select.Elements;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -84,7 +85,7 @@ public class LusciousRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
|
||||||
// Sanitizes the url removing GET parameters and convert to legacy api url.
|
// Sanitizes the url removing GET parameters and convert to legacy api url.
|
||||||
// "https://legacy.luscious.net/albums/albumname"
|
// "https://legacy.luscious.net/albums/albumname"
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user