On Mon, Mar 16, 2020 at 1:08 AM <svenme...@apache.org> wrote: > This is an automated email from the ASF dual-hosted git repository. > > svenmeier pushed a commit to branch master > in repository https://gitbox.apache.org/repos/asf/wicket.git > > > The following commit(s) were added to refs/heads/master by this push: > new bedd18a WICKET-6755 properly decode real path from uri > bedd18a is described below > > commit bedd18a4bdfaf88f15d015a3c1afaf1ad2e4fa47 > Author: =?UTF-8?q?Thorsten=20Sch=C3=B6ning?= <tschoen...@am-soft.de> > AuthorDate: Sun Mar 15 23:49:52 2020 +0100 > > WICKET-6755 properly decode real path from uri > --- > .../protocol/http/mock/MockServletContext.java | 7 ++-- > .../MockServletContextTest with spaces.txt | 1 + > .../protocol/http/mock/MockServletContextTest.java | 40 > ++++++++++++++++++++++ > 3 files changed, 46 insertions(+), 2 deletions(-) > > diff --git > a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java > b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java > index 6a0f8e6..8fc4522 100755 > --- > a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java > +++ > b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java > @@ -24,6 +24,7 @@ import java.lang.reflect.InvocationTargetException; > import java.lang.reflect.Method; > import java.lang.reflect.Proxy; > import java.net.MalformedURLException; > +import java.net.URISyntaxException; > import java.net.URL; > import java.util.Arrays; > import java.util.Collection; > @@ -408,9 +409,11 @@ public class MockServletContext implements > ServletContext > try { > URL url = getResource(name); > if (url != null) { > - return url.getFile(); > + url.getFile(); >
Is this needed to stay ? I don't see a reason > + // WICKET-6755 do not use url.getFile() as > it does not properly decode the path > + return new > File(url.toURI()).getAbsolutePath(); > } > - } catch (IOException e) { > + } catch (IOException | URISyntaxException e) { > log.error(e.getMessage(), e); > } > return null; > diff --git > a/wicket-core/src/test/java/META-INF/resources/MockServletContextTest with > spaces.txt > b/wicket-core/src/test/java/META-INF/resources/MockServletContextTest with > spaces.txt > new file mode 100644 > index 0000000..5702bf2 > --- /dev/null > +++ b/wicket-core/src/test/java/META-INF/resources/MockServletContextTest > with spaces.txt > @@ -0,0 +1 @@ > +This file's name contains spaces to ensure proper decoding of > MockServletContext#getRealPath() > \ No newline at end of file > diff --git > a/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockServletContextTest.java > b/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockServletContextTest.java > new file mode 100644 > index 0000000..aa0251f > --- /dev/null > +++ > b/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockServletContextTest.java > @@ -0,0 +1,40 @@ > +/* > + * 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.wicket.protocol.http.mock; > + > +import static org.junit.jupiter.api.Assertions.assertTrue; > + > +import org.junit.jupiter.api.Test; > + > +/** > + * Test {@link MockServletContext}. > + * > + * @author svenmeier > + */ > +public class MockServletContextTest { > + > + /** > + * WICKET-6755 > + */ > + @Test > + void spaces() { > + MockServletContext context = new MockServletContext(null, > null); > + > + String name = "MockServletContextTest with spaces.txt"; > + assertTrue(context.getRealPath(name).endsWith(name)); > + } > +} > >