Java Code Examples for org.springframework.util.StringUtils#uriDecode()

The following examples show how to use org.springframework.util.StringUtils#uriDecode() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public Mono<Resource> apply(ServerRequest request) {
	PathContainer pathContainer = request.pathContainer();
	if (!this.pattern.matches(pathContainer)) {
		return Mono.empty();
	}

	pathContainer = this.pattern.extractPathWithinPattern(pathContainer);
	String path = processPath(pathContainer.value());
	if (path.contains("%")) {
		path = StringUtils.uriDecode(path, StandardCharsets.UTF_8);
	}
	if (!StringUtils.hasLength(path) || isInvalidPath(path)) {
		return Mono.empty();
	}

	try {
		Resource resource = this.location.createRelative(path);
		if (resource.exists() && resource.isReadable() && isResourceUnderLocation(resource)) {
			return Mono.just(resource);
		}
		else {
			return Mono.empty();
		}
	}
	catch (IOException ex) {
		throw new UncheckedIOException(ex);
	}
}
 
Example 2
@Override
public Optional<Resource> apply(ServerRequest request) {
	PathContainer pathContainer = request.pathContainer();
	if (!this.pattern.matches(pathContainer)) {
		return Optional.empty();
	}

	pathContainer = this.pattern.extractPathWithinPattern(pathContainer);
	String path = processPath(pathContainer.value());
	if (path.contains("%")) {
		path = StringUtils.uriDecode(path, StandardCharsets.UTF_8);
	}
	if (!StringUtils.hasLength(path) || isInvalidPath(path)) {
		return Optional.empty();
	}

	try {
		Resource resource = this.location.createRelative(path);
		if (resource.exists() && resource.isReadable() && isResourceUnderLocation(resource)) {
			return Optional.of(resource);
		}
		else {
			return Optional.empty();
		}
	}
	catch (IOException ex) {
		throw new UncheckedIOException(ex);
	}
}
 
Example 3
@Override
public Mono<Resource> apply(ServerRequest request) {
	PathContainer pathContainer = request.pathContainer();
	if (!this.pattern.matches(pathContainer)) {
		return Mono.empty();
	}

	pathContainer = this.pattern.extractPathWithinPattern(pathContainer);
	String path = processPath(pathContainer.value());
	if (path.contains("%")) {
		path = StringUtils.uriDecode(path, StandardCharsets.UTF_8);
	}
	if (!StringUtils.hasLength(path) || isInvalidPath(path)) {
		return Mono.empty();
	}

	try {
		Resource resource = this.location.createRelative(path);
		if (resource.exists() && resource.isReadable() && isResourceUnderLocation(resource)) {
			return Mono.just(resource);
		}
		else {
			return Mono.empty();
		}
	}
	catch (IOException ex) {
		throw new UncheckedIOException(ex);
	}
}
 
Example 4
Source Project: mica   File: $.java    License: GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * url 解码
 *
 * @param source the encoded String
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String urlDecode(String source) {
	return StringUtils.uriDecode(source, Charsets.UTF_8);
}
 
Example 5
Source Project: mica   File: $.java    License: GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * url 解码
 *
 * @param source  the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String urlDecode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}
 
Example 6
Source Project: spring-analysis-note   File: UriUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param encoding the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, String encoding) {
	return StringUtils.uriDecode(source, Charset.forName(encoding));
}
 
Example 7
Source Project: spring-analysis-note   File: UriUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @since 5.0
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}
 
Example 8
Source Project: java-technology-stack   File: UriUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param encoding the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, String encoding) {
	return StringUtils.uriDecode(source, Charset.forName(encoding));
}
 
Example 9
Source Project: java-technology-stack   File: UriUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @since 5.0
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}
 
Example 10
/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 *
 * @param source the encoded String
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source) {
	return StringUtils.uriDecode(source, Charsets.UTF_8);
}
 
Example 11
/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 *
 * @param source  the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}