[ https://issues.apache.org/jira/browse/SLING-7528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16391480#comment-16391480 ]
Robert Munteanu commented on SLING-7528: ---------------------------------------- [~reschke] - here's what I started with some time ago {noformat}diff --git a/pom.xml b/pom.xml index f2834f1..74c2f27 100644 --- a/pom.xml +++ b/pom.xml @@ -177,5 +177,9 @@ <version>2.0.8</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> </dependencies> </project> diff --git a/src/test/java/org/apache/sling/jcr/webdav/impl/helper/SlingTikaDetectorTest.java b/src/test/java/org/apache/sling/jcr/webdav/impl/helper/SlingTikaDetectorTest.java new file mode 100644 index 0000000..894c667 --- /dev/null +++ b/src/test/java/org/apache/sling/jcr/webdav/impl/helper/SlingTikaDetectorTest.java @@ -0,0 +1,65 @@ +/* + * 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.sling.jcr.webdav.impl.helper; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.sling.commons.mime.MimeTypeService; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.mime.MediaType; +import org.junit.Test; + + +public class SlingTikaDetectorTest { + + private static final ByteArrayInputStream EMPTY_INPUT_STREAM = new ByteArrayInputStream(new byte[0]); + + @Test + public void noName() { + + MimeTypeService mimeTypeService = new MimeTypeService() { + + @Override + public void registerMimeType(String arg0, String... arg1) { } + + @Override + public void registerMimeType(InputStream arg0) throws IOException { // TODO Auto-generated method stub + } + + @Override + public String getMimeType(String arg0) { // TODO Auto-generated method stub + return null; + } + + @Override + public String getExtension(String arg0) { + return null; + } + }; + SlingTikaDetector detector = new SlingTikaDetector(mimeTypeService); + + Metadata metadata = new Metadata(); + + assertEquals(MediaType.OCTET_STREAM, detector.detect(EMPTY_INPUT_STREAM, metadata)); + } +} {noformat} > org.apache.sling.jcr.webdav fails for files containing "%" > ---------------------------------------------------------- > > Key: SLING-7528 > URL: https://issues.apache.org/jira/browse/SLING-7528 > Project: Sling > Issue Type: Bug > Components: JCR > Affects Versions: JCR Webdav 2.3.8 > Reporter: Julian Reschke > Priority: Major > Fix For: JCR Webdav 2.3.10 > > > Adding (PUTting) a file with a properly escaped percent sign leads to: > {noformat} > 02.03.2018 10:04:10.301 *ERROR* [127.0.0.1 [1519981450286] PUT > /content/dam/test/10%20100%25%20Total%20Success.mp3 HTTP/1.1] > org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught > Throwable > java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in > escape (%) pattern - For input string: " T" > at java.net.URLDecoder.decode(URLDecoder.java:194) > at > org.apache.sling.jcr.webdav.impl.helper.SlingTikaDetector.detect(SlingTikaDetector.java:68) > [org.apache.sling.jcr.webdav:2.3.8] > at > org.apache.jackrabbit.server.io.ImportContextImpl.<init>(ImportContextImpl.java:87) > [org.apache.sling.jcr.webdav:2.3.8] > at > org.apache.jackrabbit.webdav.simple.DavResourceImpl.getImportContext(DavResourceImpl.java:888) > [org.apache.sling.jcr.webdav:2.3.8] > at > org.apache.jackrabbit.webdav.simple.DavResourceImpl.addMember(DavResourceImpl.java:529) > [org.apache.sling.jcr.webdav:2.3.8] > {noformat} > This is because {{SlingTikaDetector}} tries to handle a URI where actually a > repository path is supplied (apart from that, the attempt to do URI parsing > is very interesting...). > The proper fix seems to be to just remove any attempt to deal with URIs here. -- This message was sent by Atlassian JIRA (v7.6.3#76005)