You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by on...@apache.org on 2018/08/14 07:43:53 UTC
[camel] branch master updated: CAMEL-12723 - remove unsafe chars in
rfc1738 which obsolete in rfc3986
This is an automated email from the ASF dual-hosted git repository.
onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new ff4c6f0 CAMEL-12723 - remove unsafe chars in rfc1738 which obsolete in rfc3986
ff4c6f0 is described below
commit ff4c6f0805a78d5e3405c1806a5ba719c19bb1c1
Author: onders <on...@apache.org>
AuthorDate: Mon Aug 13 20:13:18 2018 +0300
CAMEL-12723 - remove unsafe chars in rfc1738 which obsolete in rfc3986
---
.../camel/util/UnsafeUriCharactersEncoder.java | 26 +------
.../remote/FtpConsumerIPV6BodyAsStringTest.java | 79 ++++++++++++++++++++++
2 files changed, 82 insertions(+), 23 deletions(-)
diff --git a/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java b/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
index 8273c53..c32cfab 100644
--- a/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
+++ b/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
@@ -28,30 +28,10 @@ import java.util.regex.Pattern;
* A good source for details is <a href="http://en.wikipedia.org/wiki/Url_encode">wikipedia url encode</a> article.
*/
public final class UnsafeUriCharactersEncoder {
- private static BitSet unsafeCharactersRfc1738;
private static BitSet unsafeCharactersHttp;
private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'};
private static final Pattern RAW_PATTERN = Pattern.compile("RAW\\([^\\)]+\\)");
-
- static {
- unsafeCharactersRfc1738 = new BitSet(256);
- unsafeCharactersRfc1738.set(' ');
- unsafeCharactersRfc1738.set('"');
- unsafeCharactersRfc1738.set('<');
- unsafeCharactersRfc1738.set('>');
- unsafeCharactersRfc1738.set('#');
- unsafeCharactersRfc1738.set('%');
- unsafeCharactersRfc1738.set('{');
- unsafeCharactersRfc1738.set('}');
- unsafeCharactersRfc1738.set('|');
- unsafeCharactersRfc1738.set('\\');
- unsafeCharactersRfc1738.set('^');
- unsafeCharactersRfc1738.set('~');
- unsafeCharactersRfc1738.set('[');
- unsafeCharactersRfc1738.set(']');
- unsafeCharactersRfc1738.set('`');
- }
static {
unsafeCharactersHttp = new BitSet(256);
@@ -73,9 +53,9 @@ public final class UnsafeUriCharactersEncoder {
private UnsafeUriCharactersEncoder() {
// util class
}
-
+
public static String encode(String s) {
- return encode(s, unsafeCharactersRfc1738);
+ return encodeHttpURI(s);
}
public static String encodeHttpURI(String s) {
@@ -87,7 +67,7 @@ public final class UnsafeUriCharactersEncoder {
}
public static String encode(String s, boolean checkRaw) {
- return encode(s, unsafeCharactersRfc1738, checkRaw);
+ return encodeHttpURI(s, checkRaw);
}
public static String encodeHttpURI(String s, boolean checkRaw) {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java
new file mode 100644
index 0000000..e110cb8
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version
+ */
+public class FtpConsumerIPV6BodyAsStringTest extends FtpServerTestSupport {
+
+ private String getFtpUrl() {
+ return "ftp://admin@[::1]:" + getPort() + "/tmp4/camel?password=admin&consumer.delay=5000";
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ prepareFtpServer();
+ }
+
+ @Test
+ public void testSingleFileTest() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("Hello World");
+ mock.expectedMessageCount(1);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want to unit
+ // test that we can pool
+ Endpoint endpoint = context.getEndpoint(getFtpUrl());
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody("Hello World");
+ exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+ producer.stop();
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(getFtpUrl()).process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ String body = exchange.getIn().getBody(String.class);
+ assertNotNull(body);
+ assertEquals("Hello World", body);
+ }
+ }).to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file