@Test @SuppressWarnings( "checkstyle:magicnumber" ) public void shouldEscapeUri() throws Exception { assertThat( escapeUri( "a", UTF_8 ) ).isEqualTo( "a" ); assertThat( escapeUri( " ", UTF_8 ) ).isEqualTo( "%20" ); assertThat( escapeUri( "%", UTF_8 ) ).isEqualTo( "%25" ); assertThat( escapeUri( "+", UTF_8 ) ).isEqualTo( "%2B" ); assertThat( escapeUri( ",", UTF_8 ) ).isEqualTo( "%2C" ); assertThat( escapeUri( "/", UTF_8 ) ).isEqualTo( "/" ); assertThat( escapeUri( "7", UTF_8 ) ).isEqualTo( "7" ); assertThat( escapeUri( ":", UTF_8 ) ).isEqualTo( "%3A" ); assertThat( escapeUri( "@", UTF_8 ) ).isEqualTo( "%40" ); assertThat( escapeUri( "A", UTF_8 ) ).isEqualTo( "A" ); assertThat( escapeUri( "[", UTF_8 ) ).isEqualTo( "%5B" ); assertThat( escapeUri( "\\", UTF_8 ) ).isEqualTo( "/" ); assertThat( escapeUri( "]", UTF_8 ) ).isEqualTo( "%5D" ); assertThat( escapeUri( "`", UTF_8 ) ).isEqualTo( "%60" ); assertThat( escapeUri( "a", UTF_8 ) ).isEqualTo( "a" ); assertThat( escapeUri( "{", UTF_8 ) ).isEqualTo( "%7B" ); assertThat( escapeUri( "" + (char) 0xFF, UTF_8 ) ).isEqualTo( "%C3%BF" ); assertThat( escapeUri( "..\\..\\..\\Test : User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar", UTF_8 ) ) .isEqualTo( "../../../Test%20%3A%20User/me/.m2/repository/grp/art/1.0/art-1.0.jar" ); assertThat( escapeUri( "..\\..\\..\\Test : User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar", Charset.defaultCharset() ) ) .isEqualTo( "../../../Test%20%3A%20User/me/.m2/repository/grp/art/1.0/art-1.0.jar" ); assertThat( escapeUri( "../../surefire-its/target/junit-pathWithÜmlaut_1/target/surefire", UTF_8 ) ) .isEqualTo( "../../surefire-its/target/junit-pathWith%C3%9Cmlaut_1/target/surefire" ); String source = "../../surefire-its/target/junit-pathWithÜmlaut_1/target/surefire"; String encoded = escapeUri( "../../surefire-its/target/junit-pathWithÜmlaut_1/target/surefire", UTF_8 ); String decoded = URLDecoder.decode( encoded, UTF_8.name() ); assertThat( decoded ) .isEqualTo( source ); }
static String escapeUri( String input, Charset encoding ) { try { String uriFormEncoded = URLEncoder.encode( input, encoding.name() ); String uriPathEncoded = uriFormEncoded.replaceAll( "\\+", "%20" ); uriPathEncoded = uriPathEncoded.replaceAll( "%2F|%5C", "/" ); return uriPathEncoded; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( "avoided by using Charset" ); } }
JarManifestForkConfiguration extends AbstractClasspathForkConfiguration { static String escapeUri( String input, Charset encoding ) { try { String uriFormEncoded = URLEncoder.encode( input, encoding.name() ); String uriPathEncoded = uriFormEncoded.replaceAll( "\\+", "%20" ); uriPathEncoded = uriPathEncoded.replaceAll( "%2F|%5C", "/" ); return uriPathEncoded; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( "avoided by using Charset" ); } } }
JarManifestForkConfiguration extends AbstractClasspathForkConfiguration { static String escapeUri( String input, Charset encoding ) { try { String uriFormEncoded = URLEncoder.encode( input, encoding.name() ); String uriPathEncoded = uriFormEncoded.replaceAll( "\\+", "%20" ); uriPathEncoded = uriPathEncoded.replaceAll( "%2F|%5C", "/" ); return uriPathEncoded; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( "avoided by using Charset" ); } } @SuppressWarnings( "checkstyle:parameternumber" )  JarManifestForkConfiguration( @Nonnull Classpath bootClasspath, @Nonnull File tempDirectory,
                                         @Nullable String debugLine, @Nonnull File workingDirectory,
                                         @Nonnull Properties modelProperties, @Nullable String argLine,
                                         @Nonnull Map<String, String> environmentVariables,
                                         @Nonnull String[] excludedEnvironmentVariables,
                                         boolean debug,
                                         int forkCount, boolean reuseForks, @Nonnull Platform pluginPlatform,
                                         @Nonnull ConsoleLogger log,
                                         @Nonnull ForkNodeFactory forkNodeFactory ); }
JarManifestForkConfiguration extends AbstractClasspathForkConfiguration { static String escapeUri( String input, Charset encoding ) { try { String uriFormEncoded = URLEncoder.encode( input, encoding.name() ); String uriPathEncoded = uriFormEncoded.replaceAll( "\\+", "%20" ); uriPathEncoded = uriPathEncoded.replaceAll( "%2F|%5C", "/" ); return uriPathEncoded; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( "avoided by using Charset" ); } } @SuppressWarnings( "checkstyle:parameternumber" )  JarManifestForkConfiguration( @Nonnull Classpath bootClasspath, @Nonnull File tempDirectory,
                                         @Nullable String debugLine, @Nonnull File workingDirectory,
                                         @Nonnull Properties modelProperties, @Nullable String argLine,
                                         @Nonnull Map<String, String> environmentVariables,
                                         @Nonnull String[] excludedEnvironmentVariables,
                                         boolean debug,
                                         int forkCount, boolean reuseForks, @Nonnull Platform pluginPlatform,
                                         @Nonnull ConsoleLogger log,
                                         @Nonnull ForkNodeFactory forkNodeFactory );  }
JarManifestForkConfiguration extends AbstractClasspathForkConfiguration { static String escapeUri( String input, Charset encoding ) { try { String uriFormEncoded = URLEncoder.encode( input, encoding.name() ); String uriPathEncoded = uriFormEncoded.replaceAll( "\\+", "%20" ); uriPathEncoded = uriPathEncoded.replaceAll( "%2F|%5C", "/" ); return uriPathEncoded; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( "avoided by using Charset" ); } } @SuppressWarnings( "checkstyle:parameternumber" )  JarManifestForkConfiguration( @Nonnull Classpath bootClasspath, @Nonnull File tempDirectory,
                                         @Nullable String debugLine, @Nonnull File workingDirectory,
                                         @Nonnull Properties modelProperties, @Nullable String argLine,
                                         @Nonnull Map<String, String> environmentVariables,
                                         @Nonnull String[] excludedEnvironmentVariables,
                                         boolean debug,
                                         int forkCount, boolean reuseForks, @Nonnull Platform pluginPlatform,
                                         @Nonnull ConsoleLogger log,
                                         @Nonnull ForkNodeFactory forkNodeFactory );   }