summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java30
2 files changed, 27 insertions, 6 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java
index da6505d3..5f363d3d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java
@@ -17,6 +17,7 @@ package at.asit.pdfover.gui.bku.mobile;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -249,6 +250,7 @@ public abstract class MobileBKUHandler {
}
if (redirectLocation != null) {
+ redirectLocation = MobileBKUHelper.getQualifiedURL(redirectLocation, new URL(post.getURI().toString()));
redirectLocation = getStatus().ensureSessionID(redirectLocation);
log.debug("Redirected to " + redirectLocation); //$NON-NLS-1$
get = new GetMethod(redirectLocation);
@@ -332,6 +334,7 @@ public abstract class MobileBKUHandler {
}
if (redirectLocation != null) {
+ redirectLocation = MobileBKUHelper.getQualifiedURL(redirectLocation, new URL(get.getURI().toString()));
redirectLocation = getStatus().ensureSessionID(redirectLocation);
log.debug("Redirected to " + redirectLocation); //$NON-NLS-1$
get2 = new GetMethod(redirectLocation);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java
index 213aea08..1e4431a4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java
@@ -16,6 +16,7 @@
package at.asit.pdfover.gui.bku.mobile;
// Imports
+import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -167,7 +168,7 @@ public class MobileBKUHelper {
String param, String value) throws Exception {
String found = extractTagWithParam(data, tag, param, value);
int startidx = data.indexOf(found) + found.length();
- int endidx = data.indexOf("</" + tag + ">"); //$NON-NLS-1$ //$NON-NLS-2$
+ int endidx = data.indexOf("</" + tag + ">", startidx); //$NON-NLS-1$ //$NON-NLS-2$
if (endidx == -1) {
log.error("extracting tag: closing tag not found! " + tag + " (" + param + "=" + value + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
throw new Exception("Tag not found! Mobile BKU site changed?"); //$NON-NLS-1$
@@ -235,16 +236,33 @@ public class MobileBKUHelper {
/**
* Removes file extension from URL
*
- * @param query
+ * @param url
* the url string
* @return the stripped url
*/
- public static String stripQueryString(String query) {
- int pathidx = query.lastIndexOf('/');
+ public static String stripQueryString(String url) {
+ int pathidx = url.lastIndexOf('/');
if (pathidx > 0) {
- return query.substring(0, pathidx);
+ return url.substring(0, pathidx);
}
- return query;
+ return url;
+ }
+
+ /**
+ * Build a fully qualified URL out of a base URL plus a URL fragment
+ * @param fragment the URL fragment
+ * @param base the base URL
+ * @return the fully qualified URL
+ */
+ public static String getQualifiedURL(String fragment, URL base) {
+ if (fragment.startsWith("http:") || fragment.startsWith("https:")) //$NON-NLS-1$ //$NON-NLS-2$
+ return fragment;
+ int p = base.getPort();
+ String port = ((p != -1) && (p != base.getDefaultPort())) ? ":" + p : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ if (fragment.startsWith("/")) { //$NON-NLS-1$
+ return base.getProtocol() + "://" + base.getHost() + port + fragment; //$NON-NLS-1$
+ }
+ return stripQueryString(base.toString()) + "/" + fragment; //$NON-NLS-1$
}
/**