fix plus parsing

This commit is contained in:
Jörg Prante 2019-04-16 23:58:09 +02:00
parent a63557cdd9
commit 1f949104ef
10 changed files with 97 additions and 10 deletions

View file

@ -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'

View file

@ -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

Binary file not shown.

View file

@ -1,6 +1,6 @@
#Thu Jan 17 15:23:55 CET 2019
#Tue Apr 16 23:50:27 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-all.zip

18
gradlew vendored
View file

@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

18
gradlew.bat vendored
View file

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View file

@ -20,7 +20,7 @@ import java.util.SortedSet;
* A limited multi-map of HTTP request parameters. Each key references a
* limited set of parameters collected from the request during message
* signing. Parameter values are sorted as per
* <a href="http://oauth.net/core/1.0a/#anchor13">OAuth specification</a></a>.
* <a href="http://oauth.net/core/1.0a/#anchor13">OAuth specification</a>.
* 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<String, SortedSet<String>> {
* @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<String, SortedSet<String>> {
* @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<String, SortedSet<String>> {
* @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<String, SortedSet<String>> {
}
/**
* Convenience method to merge a Map<String, List<String>>.
* Convenience method to merge a {@code Map<String, List<String>>}.
*
* @param m the map
*/
@ -226,6 +232,8 @@ public class HttpParameters implements Map<String, SortedSet<String>> {
* 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<String, SortedSet<String>> {
*
* @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<String, SortedSet<String>> {
* @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 {

View file

@ -253,6 +253,7 @@ public class URL implements Comparable<URL> {
/**
* 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<URL> {
/**
* Get the percent-decoded path of the {@code URL} if it exists.
* @return decoded path
*/
public String getDecodedPath() {
return decode(path);

View file

@ -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");

View file

@ -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());
}