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

The following examples show how to use org.springframework.util.StringUtils#uriDecode() . 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
Source File: PathResourceLookupFunction.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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
Source File: PathResourceLookupFunction.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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
Source File: PathResourceLookupFunction.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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 File: $.java    From mica with 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 File: $.java    From mica with 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 File: UriUtils.java    From spring-analysis-note with 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 File: UriUtils.java    From spring-analysis-note with 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 File: UriUtils.java    From java-technology-stack with 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 File: UriUtils.java    From java-technology-stack with 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
Source File: Func.java    From blade-tool with GNU Lesser General Public License v3.0 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
 * @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
Source File: Func.java    From blade-tool with GNU Lesser General Public License v3.0 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
 * @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);
}