Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
d207c229
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d207c229
编写于
3月 02, 2010
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed wrong encoding of URI templates with @-signs (SPR-6874)
上级
e653a9cd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
7 deletion
+17
-7
org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java
...c/main/java/org/springframework/web/util/UriTemplate.java
+5
-6
org.springframework.web/src/main/java/org/springframework/web/util/UriUtils.java
.../src/main/java/org/springframework/web/util/UriUtils.java
+1
-1
org.springframework.web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
...ingframework/web/client/RestTemplateIntegrationTests.java
+3
-0
org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java
...t/java/org/springframework/web/util/UriTemplateTests.java
+7
-0
org.springframework.web/src/test/java/org/springframework/web/util/UriUtilsTest.java
.../test/java/org/springframework/web/util/UriUtilsTest.java
+1
-0
未找到文件。
org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java
浏览文件 @
d207c229
...
...
@@ -182,7 +182,7 @@ public class UriTemplate {
throw
new
IllegalStateException
(
ex
);
}
catch
(
URISyntaxException
ex
)
{
throw
new
IllegalArgumentException
(
"Could not create URI from ["
+
uri
+
"]: "
+
ex
);
throw
new
IllegalArgumentException
(
"Could not create URI from ["
+
uri
+
"]: "
+
ex
,
ex
);
}
}
...
...
@@ -201,24 +201,23 @@ public class UriTemplate {
Matcher
m
=
NAMES_PATTERN
.
matcher
(
uriTemplate
);
int
end
=
0
;
while
(
m
.
find
())
{
this
.
patternBuilder
.
append
(
encodeAndQ
uote
(
uriTemplate
,
end
,
m
.
start
()));
this
.
patternBuilder
.
append
(
q
uote
(
uriTemplate
,
end
,
m
.
start
()));
this
.
patternBuilder
.
append
(
VALUE_REGEX
);
this
.
variableNames
.
add
(
m
.
group
(
1
));
end
=
m
.
end
();
}
this
.
patternBuilder
.
append
(
encodeAndQ
uote
(
uriTemplate
,
end
,
uriTemplate
.
length
()));
this
.
patternBuilder
.
append
(
q
uote
(
uriTemplate
,
end
,
uriTemplate
.
length
()));
int
lastIdx
=
this
.
patternBuilder
.
length
()
-
1
;
if
(
lastIdx
>=
0
&&
this
.
patternBuilder
.
charAt
(
lastIdx
)
==
'/'
)
{
this
.
patternBuilder
.
deleteCharAt
(
lastIdx
);
}
}
private
String
encodeAndQ
uote
(
String
fullPath
,
int
start
,
int
end
)
{
private
String
q
uote
(
String
fullPath
,
int
start
,
int
end
)
{
if
(
start
==
end
)
{
return
""
;
}
String
result
=
encodeUri
(
fullPath
.
substring
(
start
,
end
)).
toASCIIString
();
return
Pattern
.
quote
(
result
);
return
Pattern
.
quote
(
fullPath
.
substring
(
start
,
end
));
}
private
List
<
String
>
getVariableNames
()
{
...
...
org.springframework.web/src/main/java/org/springframework/web/util/UriUtils.java
浏览文件 @
d207c229
...
...
@@ -61,7 +61,7 @@ public abstract class UriUtils {
private
static
final
String
SCHEME_PATTERN
=
"([^:/?#]+):"
;
private
static
final
String
USERINFO_PATTERN
=
"([^@]*)"
;
private
static
final
String
USERINFO_PATTERN
=
"([^@
/
]*)"
;
private
static
final
String
HOST_PATTERN
=
"([^/?#:]*)"
;
...
...
org.springframework.web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
浏览文件 @
d207c229
...
...
@@ -127,6 +127,9 @@ public class RestTemplateIntegrationTests {
public
void
uri
()
throws
InterruptedException
,
URISyntaxException
{
String
result
=
template
.
getForObject
(
URI
+
"/uri/{query}"
,
String
.
class
,
"Z\u00fcrich"
);
assertEquals
(
"Invalid request URI"
,
"/uri/Z%FCrich"
,
result
);
result
=
template
.
getForObject
(
URI
+
"/uri/query={query}"
,
String
.
class
,
"foo@bar"
);
assertEquals
(
"Invalid request URI"
,
"/uri/query=foo@bar"
,
result
);
}
/** Servlet that returns and error message for a given status code. */
...
...
org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java
浏览文件 @
d207c229
...
...
@@ -152,4 +152,11 @@ public class UriTemplateTests {
assertEquals
(
"/$replacement"
,
uri
.
toString
());
}
@Test
public
void
expandWithAtSign
()
{
UriTemplate
template
=
new
UriTemplate
(
"http://localhost/query={query}"
);
URI
uri
=
template
.
expand
(
"foo@bar"
);
assertEquals
(
"http://localhost/query=foo@bar"
,
uri
.
toString
());
}
}
org.springframework.web/src/test/java/org/springframework/web/util/UriUtilsTest.java
浏览文件 @
d207c229
...
...
@@ -117,6 +117,7 @@ public class UriUtilsTest {
assertEquals
(
"Invalid encoded URI"
,
"../../../demo/jfc/SwingSet2/src/SwingSet2.java"
,
UriUtils
.
encodeUri
(
"../../../demo/jfc/SwingSet2/src/SwingSet2.java"
,
ENC
));
assertEquals
(
"Invalid encoded URI"
,
"file:///~/calendar"
,
UriUtils
.
encodeUri
(
"file:///~/calendar"
,
ENC
));
assertEquals
(
"Invalid encoded URI"
,
"http://example.com/query=foo@bar"
,
UriUtils
.
encodeUri
(
"http://example.com/query=foo@bar"
,
ENC
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录