private String buildPathFrom(URI uri, String host) { String pathStr = uri.toString(); pathStr = pathStr.replace(host, ""); pathStr = pathStr.replace("git://", "").replace("default://", ""); pathStr = EncodingUtil.decode(pathStr); if (pathStr.startsWith("/:")) { pathStr = pathStr.substring(2); } return pathStr; }
private String encodePath(final String s) { return EncodingUtil.encodePath(s); }
/** * Escape and encode a string regarded as the path component of an URI with * the default protocol charset. * @param unescaped an unescaped string * @return the escaped string */ public static String encodePath(String unescaped) { byte[] rawdata = URLCodec.encodeUrl(allowed_abs_path, getBytes(unescaped, "UTF-8")); return getAsciiString(rawdata); }
/** * Unescape and decode a given string regarded as an escaped string with the * UTF-8 protocol charset. * @param escaped a string * @return the unescaped string * @throws IllegalStateException if the escaped string is not a correct URL */ public static String decode(String escaped) { byte[] asciiData = getAsciiBytes(escaped); byte[] rawdata; try { rawdata = URLCodec.decodeUrl(asciiData); } catch (DecoderException e) { throw new IllegalStateException(e.getMessage()); } return getString(rawdata, "UTF-8"); } }
/** * Unescape and decode a given string regarded as an escaped string with the * UTF-8 protocol charset. * @param escaped a string * @return the unescaped string * @throws IllegalStateException if the escaped string is not a correct URL */ public static String decode(String escaped) { byte[] asciiData = getAsciiBytes(escaped); byte[] rawdata; try { rawdata = URLCodec.decodeUrl(asciiData); } catch (DecoderException e) { throw new IllegalStateException(e.getMessage()); } return getString(rawdata, "UTF-8"); } }
private String destinationPath(final Path resource) { final String destinationPath = EncodingUtil.decode(resource.toUri().toString().substring(projectPrefix.length())); if (destinationPath.startsWith("/")) { // File in sub module return destinationPath.substring(1); } else { // File in main module return destinationPath; } }
/** * Escape and encode a string regarded as the path component of an URI with * the default protocol charset. * @param unescaped an unescaped string * @return the escaped string */ public static String encodePath(String unescaped) { byte[] rawdata = URLCodec.encodeUrl(allowed_abs_path, getBytes(unescaped, "UTF-8")); return getAsciiString(rawdata); }
private String encodePath(final String s) { return EncodingUtil.encodePath(s); }
final String _filename = EncodingUtil.decode(req.getRequestURI().substring(req.getContextPath().length())); final String filename; if (_filename.toLowerCase().endsWith("?preview")) {
@Test public void testSimpleBranchedGitRoot2Spaced() throws IllegalStateException { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, EncodingUtil.decode("/path/to/some/some%20place.txt"), "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/some place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/some%20place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isEqualTo("path"); assertThat(path.getRoot().toString()).isEqualTo("/"); }
@Test public void testSimpleBranchedGitRoot2Spaced() throws IllegalStateException { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, EncodingUtil.decode("/path/to/some/some%20place.txt"), "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/some place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/some%20place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isEqualTo("path"); assertThat(path.getRoot().toString()).isEqualTo("/"); }