Fixed URI encoding in URIEditor to be RFC 2396 compliant

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@682 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma
2009-02-24 15:12:54 +00:00
parent 7b9343ac4f
commit 39d5376d73
2 changed files with 46 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,10 +105,19 @@ public class URIEditor extends PropertyEditorSupport {
* constructor, replacing spaces with "%20" quotes first.
* @param value the value to convert into a URI instance
* @return the URI instance
* @throws URISyntaxException if URI conversion failed
* @throws java.net.URISyntaxException if URI conversion failed
*/
protected URI createURI(String value) throws URISyntaxException {
return new URI(StringUtils.replace(value, " ", "%20"));
int idx = value.indexOf(':');
if (idx != -1) {
String scheme = value.substring(0, idx);
String ssp = value.substring(idx + 1);
return new URI(scheme, ssp, null);
}
else {
// value contains no scheme, fallback to default
return new URI(value);
}
}