aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-08-27 12:17:19 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-08-27 12:17:19 +0200
commitc42e3d7000982f249f5e1e85a5f379b5ed0e49b6 (patch)
tree9a478dc54f8cb3e5b0f92d0f0db001ee5c44ab24 /pdf-as-web/src/main/java/at/gv
parent47b670c2804368274cfcbadde3ed160dbfb69ef7 (diff)
downloadpdf-as-4-c42e3d7000982f249f5e1e85a5f379b5ed0e49b6.tar.gz
pdf-as-4-c42e3d7000982f249f5e1e85a5f379b5ed0e49b6.tar.bz2
pdf-as-4-c42e3d7000982f249f5e1e85a5f379b5ed0e49b6.zip
Fixed empty Query String bug
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java44
1 files changed, 25 insertions, 19 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java
index 4c793524..64043cac 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java
@@ -11,36 +11,42 @@ import java.util.Map.Entry;
public class UrlParameterExtractor {
-
- public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {
- Map<String, String> query_pairs = new LinkedHashMap<String, String>();
- String query = url.getQuery();
- String[] pairs = query.split("&");
- for (String pair : pairs) {
- int idx = pair.indexOf("=");
- query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
- }
- return query_pairs;
+ public static Map<String, String> splitQuery(URL url)
+ throws UnsupportedEncodingException {
+ Map<String, String> query_pairs = new LinkedHashMap<String, String>();
+ String query = url.getQuery();
+ if (query != null) {
+ String[] pairs = query.split("&");
+ for (String pair : pairs) {
+ int idx = pair.indexOf("=");
+ query_pairs.put(
+ URLDecoder.decode(pair.substring(0, idx), "UTF-8"),
+ URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
+ }
+ }
+ return query_pairs;
}
-
+
public static String buildParameterFormString(URL url) throws IOException {
Map<String, String> query_pairs = splitQuery(url);
- Iterator<Entry<String, String>> entryIt = query_pairs.entrySet().iterator();
-
- if(query_pairs.isEmpty()) {
+ Iterator<Entry<String, String>> entryIt = query_pairs.entrySet()
+ .iterator();
+
+ if (query_pairs.isEmpty()) {
return "";
}
String genericTemplate = PdfAsHelper.getGenericTemplate();
StringBuilder sb = new StringBuilder();
- while(entryIt.hasNext()) {
+ while (entryIt.hasNext()) {
Entry<String, String> entry = entryIt.next();
-
- String current = genericTemplate.replace("##NAME##", entry.getKey());
+
+ String current = genericTemplate
+ .replace("##NAME##", entry.getKey());
current = current.replace("##VALUE##", entry.getValue());
sb.append(current);
}
-
+
return sb.toString();
}
-
+
}