From 1f949104efddb1f65ccd561fc5950df2bb2a68cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Tue, 16 Apr 2019 23:58:09 +0200 Subject: [PATCH] fix plus parsing --- build.gradle | 6 ++-- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.jar | Bin 55190 -> 55616 bytes gradle/wrapper/gradle-wrapper.properties | 4 +-- gradlew | 18 +++++++++- gradlew.bat | 18 +++++++++- .../org/xbib/net/http/HttpParameters.java | 16 +++++++-- net-url/src/main/java/org/xbib/net/URL.java | 2 ++ .../test/java/org/xbib/net/URLParserTest.java | 10 ++++++ .../org/xbib/net/path/PathDecoderTest.java | 31 ++++++++++++++++++ 10 files changed, 97 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 3d514a0..4c13ffe 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ subprojects { targetCompatibility = JavaVersion.VERSION_1_8 } tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:all,-serial" << "-profile" << "compact1" + options.compilerArgs << "-Xlint:all,-serial" } jar { @@ -89,7 +89,7 @@ subprojects { imagesdir: 'img' } - javadoc { + /*javadoc { options.docletpath = configurations.asciidoclet.files.asType(List) options.doclet = 'org.asciidoctor.Asciidoclet' //options.overview = "src/docs/asciidoclet/overview.adoc" @@ -99,7 +99,7 @@ subprojects { configure(options) { noTimestamp = true } - } + }*/ task sourcesJar(type: Jar, dependsOn: classes) { classifier 'sources' diff --git a/gradle.properties b/gradle.properties index 3a575d7..c4f9d50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = net -version = 1.2.1 +version = 1.2.2 jackson.version = 2.8.11 junit.version = 4.12 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738cbd051603d91cc39de6cb000dd98fe6b02..5c2d1cf016b3885f6930543d57b744ea8c220a1a 100644 GIT binary patch delta 3320 zcmai0c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6jz}f($PrOb`S;imdEwtu`#cCu3aMXBgUUH4t2j_qu=KmOO645(v(_DL z^G5PF%RR0@X5D{(V%x5L{xD1Sa>^wR+$0j(DeVfwk;tp3<@i$~qOsvx^uUy!zV8G0~0`$f?VV=?vm zOwYnZB>UV_b#sh6ibtN`5I+l%mTE9T%*J!xaz}cWisUNLg@>nEiKv4hgmv`5C)GIDbBOgq{?5K-!=>z{CLJ$wIBkL-~yV{}~e*^#eZ1f%)RR;DgcM zfOqnA#42!t$D;@!QT3n50ve1d0$Zl^m}ABc){bz2HDhq#o&{ZLlQ=*lO9Alv7y_uW z`bTL2KkVsP<{%6$`1yeL}DmCZuxPZRJp*( z*Kk1M23@g@UjhQ6PEZ{58CL@Aqv>cB0|#ltT;SR`95{}ptMe0@zz&v<>j{GNDt-bE zn5EFw?u0e)Ee+J0^aq@C>E_j>A%MyU^@?Rcohe{^TCd{d<=ub5$bWAhOAuth specification. + * OAuth specification. * Every key/value pair will be percent-encoded upon insertion. * This class has special semantics tailored to * being useful for message signing; it's not a general purpose collection class @@ -130,6 +130,8 @@ public class HttpParameters implements Map> { * @param key the parameter name * @param value the parameter value * @return the value + * @throws MalformedInputException if input is malformed + * @throws UnmappableCharacterException if characters are unmappable */ public String put(String key, String value) throws MalformedInputException, UnmappableCharacterException { @@ -145,6 +147,8 @@ public class HttpParameters implements Map> { * @param percentEncode whether key and value should be percent encoded before being * inserted into the map * @return the value + * @throws MalformedInputException if input is malformed + * @throws UnmappableCharacterException if characters are unmappable */ public String put(String key, String value, boolean percentEncode) throws MalformedInputException, UnmappableCharacterException { @@ -169,6 +173,8 @@ public class HttpParameters implements Map> { * @param key the parameter name * @param nullString can be anything, but probably... null? * @return null + * @throws MalformedInputException if input is malformed + * @throws UnmappableCharacterException if characters are unmappable */ public String putNull(String key, String nullString) throws MalformedInputException, UnmappableCharacterException { @@ -194,7 +200,7 @@ public class HttpParameters implements Map> { } /** - * Convenience method to merge a Map>. + * Convenience method to merge a {@code Map>}. * * @param m the map */ @@ -226,6 +232,8 @@ public class HttpParameters implements Map> { * characters!) * @param percentDecode whether the value being retrieved should be percent decoded * @return the first value found for this parameter + * @throws MalformedInputException if input is malformed + * @throws UnmappableCharacterException if characters are unmappable */ public String getFirst(String key, boolean percentDecode) throws MalformedInputException, UnmappableCharacterException { @@ -243,6 +251,8 @@ public class HttpParameters implements Map> { * * @param key the parameter name * @return the query string + * @throws MalformedInputException if input is malformed + * @throws UnmappableCharacterException if characters are unmappable */ public String getAsQueryString(String key) throws MalformedInputException, UnmappableCharacterException { @@ -257,6 +267,8 @@ public class HttpParameters implements Map> { * @param percentEncode whether key should be percent encoded before being * used with the map * @return the query string + * @throws MalformedInputException if input is malformed + * @throws UnmappableCharacterException if characters are unmappable */ public String getAsQueryString(String key, boolean percentEncode) throws MalformedInputException, UnmappableCharacterException { diff --git a/net-url/src/main/java/org/xbib/net/URL.java b/net-url/src/main/java/org/xbib/net/URL.java index 302c602..0e225ba 100755 --- a/net-url/src/main/java/org/xbib/net/URL.java +++ b/net-url/src/main/java/org/xbib/net/URL.java @@ -253,6 +253,7 @@ public class URL implements Comparable { /** * Return a special URL denoting the fact that this URL should be considered as invalid. * The URL has a null scheme. + * @return url */ public static URL nullUrl() { return NULL_URL; @@ -409,6 +410,7 @@ public class URL implements Comparable { /** * Get the percent-decoded path of the {@code URL} if it exists. + * @return decoded path */ public String getDecodedPath() { return decode(path); diff --git a/net-url/src/test/java/org/xbib/net/URLParserTest.java b/net-url/src/test/java/org/xbib/net/URLParserTest.java index ebfd6c4..1ef99de 100644 --- a/net-url/src/test/java/org/xbib/net/URLParserTest.java +++ b/net-url/src/test/java/org/xbib/net/URLParserTest.java @@ -159,6 +159,16 @@ public class URLParserTest { assertRoundTrip(url.toExternalForm()); } + @Test + public void testPassword() throws Exception { + URL url = URL.from("ftp://aaa:b%2B1@www.google.com"); + assertEquals("b+1", url.getPassword()); + assertRoundTrip(url.toExternalForm()); + url = URL.from("ftp://aaa:b+1@www.google.com"); + assertEquals("b+1", url.getPassword()); + assertRoundTrip(url.toExternalForm()); + } + @Test public void testPlus() throws Exception { URL url = URL.from("http://foobar:8080/test/print?value=%EA%B0%80+%EB%82%98"); diff --git a/net-url/src/test/java/org/xbib/net/path/PathDecoderTest.java b/net-url/src/test/java/org/xbib/net/path/PathDecoderTest.java index b6082ba..3aca363 100644 --- a/net-url/src/test/java/org/xbib/net/path/PathDecoderTest.java +++ b/net-url/src/test/java/org/xbib/net/path/PathDecoderTest.java @@ -1,10 +1,15 @@ package org.xbib.net.path; import org.junit.Test; +import org.xbib.net.URL; import static org.junit.Assert.assertEquals; +import java.nio.charset.MalformedInputException; import java.nio.charset.StandardCharsets; +import java.nio.charset.UnmappableCharacterException; +import java.util.logging.Level; +import java.util.logging.Logger; /** */ @@ -37,4 +42,30 @@ public class PathDecoderTest { assertEquals("[b c]", decoder.params().get("a").toString()); assertEquals("[e f]", decoder.params().get("d").toString()); } + + @Test + public void testPlusPercent() throws Exception { + PathDecoder decoder = new PathDecoder("//path?a=b%2Bc", "d=e%2Bf", StandardCharsets.UTF_8); + assertEquals("/path", decoder.path()); + assertEquals("[b+c]", decoder.params().get("a").toString()); + assertEquals("[e+f]", decoder.params().get("d").toString()); + } + + @Test + public void decodeURL() throws MalformedInputException, UnmappableCharacterException { + String requestURI = "/pdfconverter/index.gtpl?x-fl-key=20190035592&x-fl-source=ftp://DE-465:r09t00k25@herakles.hbz-nrw.de/fl/upload/20190035592/20190035592.pdf&x-fl-target=ftp://DE-1073:haribo%2B1@herakles.hbz-nrw.de/fl/download/20190035592/Fernleihe_Kopienlieferung_null_FB201900373_BLQDMT62_20190035592_20190035592.pdf&x-fl-copy=&x-fl-ack=https://fl.hbz-nrw.de/app/ack/index.gtpl&x-fl-pages=1-"; + URL url = URL.builder().path(requestURI).build(); + log.log(Level.INFO, "URL: url=" + url + " path=" + url.getPath() + " query=" + url.getQuery() + + " fragment=" + url.getFragment()); + PathDecoder decoder = new PathDecoder(requestURI, StandardCharsets.UTF_8); + if (url.getQuery() != null) { + decoder.parse(url.getDecodedQuery()); + } + log.log(Level.INFO, "decoded query=" + url.getDecodedQuery()); + log.log(Level.INFO, "path decoder params=" + decoder.params()); + url = URL.from(decoder.params().get("x-fl-target").get(0)); + log.log(Level.INFO, "url=" + url); + } + + private static final Logger log = Logger.getLogger(PathDecoderTest.class.getName()); }