[camel] branch camel-2.21.x updated (cbcf30d -> b27cc1a)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch camel-2.21.x updated (cbcf30d -> b27cc1a)

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from cbcf30d  CAMEL-12565: Added unit tests. Fixed a little issue in validator to ensure exception is set on exchange to allow advice to keep executing the next ones.
     new 9f76845  CAMEL-12713 - XsltUriResolver fix: relative paths can remove scheme from XSLT URI (#2456)
     new b27cc1a  CAMEL-12713: Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/camel/builder/xml/XsltUriResolver.java  |  7 ++-
 .../xml/XsltUriResolverTest.java}                  | 69 +++++++++++-----------
 2 files changed, 39 insertions(+), 37 deletions(-)
 copy camel-core/src/test/java/org/apache/camel/{management/CamelContextDisableJmxTest.java => builder/xml/XsltUriResolverTest.java} (64%)

Reply | Threaded
Open this post in threaded view
|

[camel] 01/02: CAMEL-12713 - XsltUriResolver fix: relative paths can remove scheme from XSLT URI (#2456)

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9f768457caa9e456396c99925a24626b82f6ec03
Author: Peter Van den Bosch <[hidden email]>
AuthorDate: Tue Aug 7 14:02:35 2018 +0200

    CAMEL-12713 - XsltUriResolver fix: relative paths can remove scheme from XSLT URI (#2456)
---
 .../org/apache/camel/builder/xml/XsltUriResolver.java  |  7 +++++--
 .../apache/camel/builder/xml/XsltUriResolverTest.java  | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/camel-core/src/main/java/org/apache/camel/builder/xml/XsltUriResolver.java b/camel-core/src/main/java/org/apache/camel/builder/xml/XsltUriResolver.java
index c7d528c..7b3866d 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/xml/XsltUriResolver.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/xml/XsltUriResolver.java
@@ -27,6 +27,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ResourceHelper;
+import org.apache.camel.util.StringHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -74,14 +75,16 @@ public class XsltUriResolver implements URIResolver {
         LOG.trace("Resolving URI with href: {} and base: {}", href, base);
 
         String scheme = ResourceHelper.getScheme(href);
+
         if (scheme != null) {
             // need to compact paths for file/classpath as it can be relative paths using .. to go backwards
+            String hrefPath = StringHelper.after(href, scheme);
             if ("file:".equals(scheme)) {
                 // compact path use file OS separator
-                href = FileUtil.compactPath(href);
+                href = scheme + FileUtil.compactPath(hrefPath);
             } else if ("classpath:".equals(scheme)) {
                 // for classpath always use /
-                href = FileUtil.compactPath(href, '/');
+                href = scheme + FileUtil.compactPath(hrefPath, '/');
             }
             LOG.debug("Resolving URI from {}: {}", scheme, href);
 
diff --git a/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java b/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java
new file mode 100644
index 0000000..6d4df9e
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java
@@ -0,0 +1,18 @@
+package org.apache.camel.builder.xml;
+
+import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+
+import javax.xml.transform.Source;
+
+public class XsltUriResolverTest extends TestCase {
+
+    public void testResolveUri() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        XsltUriResolver xsltUriResolver = new XsltUriResolver(context, "classpath:xslt/staff/staff.xsl");
+        Source source = xsltUriResolver.resolve("../../xslt/common/staff_template.xsl", "classpath:xslt/staff/staff.xsl");
+        assertNotNull(source);
+        assertEquals("classpath:xslt/common/staff_template.xsl", source.getSystemId());
+    }
+}

Reply | Threaded
Open this post in threaded view
|

[camel] 02/02: CAMEL-12713: Fixed CS

davsclaus-2
In reply to this post by davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b27cc1acf0601810381743dfb58d9fb7cb61fc46
Author: Claus Ibsen <[hidden email]>
AuthorDate: Tue Aug 7 14:05:04 2018 +0200

    CAMEL-12713: Fixed CS
---
 .../camel/builder/xml/XsltUriResolverTest.java       | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java b/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java
index 6d4df9e..99fe59f 100644
--- a/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java
+++ b/camel-core/src/test/java/org/apache/camel/builder/xml/XsltUriResolverTest.java
@@ -1,11 +1,27 @@
+/**
+ * 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.builder.xml;
 
+import javax.xml.transform.Source;
+
 import junit.framework.TestCase;
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
 
-import javax.xml.transform.Source;
-
 public class XsltUriResolverTest extends TestCase {
 
     public void testResolveUri() throws Exception {