Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4ac0465e
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ac0465e
编写于
8月 19, 2013
作者:
X
xuelei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8020842: IDN do not throw IAE when hostname ends with a trailing dot
Reviewed-by: weijun, michaelm
上级
f51d266b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
164 addition
and
5 deletion
+164
-5
src/share/classes/java/net/IDN.java
src/share/classes/java/net/IDN.java
+38
-5
test/java/net/IDN/IllegalArg.java
test/java/net/IDN/IllegalArg.java
+72
-0
test/sun/security/ssl/javax/net/ssl/ServerName/IllegalSNIName.java
...security/ssl/javax/net/ssl/ServerName/IllegalSNIName.java
+54
-0
未找到文件。
src/share/classes/java/net/IDN.java
浏览文件 @
4ac0465e
...
...
@@ -113,11 +113,18 @@ public final class IDN {
int
p
=
0
,
q
=
0
;
StringBuffer
out
=
new
StringBuffer
();
if
(
isRootLabel
(
input
))
{
return
"."
;
}
while
(
p
<
input
.
length
())
{
q
=
searchDots
(
input
,
p
);
out
.
append
(
toASCIIInternal
(
input
.
substring
(
p
,
q
),
flag
));
if
(
q
!=
(
input
.
length
()))
{
// has more labels, or keep the trailing dot as at present
out
.
append
(
'.'
);
}
p
=
q
+
1
;
if
(
p
<
input
.
length
())
out
.
append
(
'.'
);
}
return
out
.
toString
();
...
...
@@ -167,11 +174,18 @@ public final class IDN {
int
p
=
0
,
q
=
0
;
StringBuffer
out
=
new
StringBuffer
();
if
(
isRootLabel
(
input
))
{
return
"."
;
}
while
(
p
<
input
.
length
())
{
q
=
searchDots
(
input
,
p
);
out
.
append
(
toUnicodeInternal
(
input
.
substring
(
p
,
q
),
flag
));
if
(
q
!=
(
input
.
length
()))
{
// has more labels, or keep the trailing dot as at present
out
.
append
(
'.'
);
}
p
=
q
+
1
;
if
(
p
<
input
.
length
())
out
.
append
(
'.'
);
}
return
out
.
toString
();
...
...
@@ -263,6 +277,13 @@ public final class IDN {
dest
=
new
StringBuffer
(
label
);
}
// step 8, move forward to check the smallest number of the code points
// the length must be inside 1..63
if
(
dest
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"Empty label is not a legal name"
);
}
// step 3
// Verify the absence of non-LDH ASCII code points
// 0..0x2c, 0x2e..0x2f, 0x3a..0x40, 0x5b..0x60, 0x7b..0x7f
...
...
@@ -311,7 +332,7 @@ public final class IDN {
// step 8
// the length must be inside 1..63
if
(
dest
.
length
()
>
MAX_LABEL_LENGTH
)
{
if
(
dest
.
length
()
>
MAX_LABEL_LENGTH
)
{
throw
new
IllegalArgumentException
(
"The label in the input is too long"
);
}
...
...
@@ -409,8 +430,7 @@ public final class IDN {
private
static
int
searchDots
(
String
s
,
int
start
)
{
int
i
;
for
(
i
=
start
;
i
<
s
.
length
();
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
c
==
'.'
||
c
==
'\u3002'
||
c
==
'\
uFF0E
'
||
c
==
'\
uFF61
'
)
{
if
(
isLabelSeparator
(
s
.
charAt
(
i
)))
{
break
;
}
}
...
...
@@ -418,6 +438,19 @@ public final class IDN {
return
i
;
}
//
// to check if a string is a root label, ".".
//
private
static
boolean
isRootLabel
(
String
s
)
{
return
(
s
.
length
()
==
1
&&
isLabelSeparator
(
s
.
charAt
(
0
)));
}
//
// to check if a character is a label separator, i.e. a dot character.
//
private
static
boolean
isLabelSeparator
(
char
c
)
{
return
(
c
==
'.'
||
c
==
'\u3002'
||
c
==
'\
uFF0E
'
||
c
==
'\
uFF61
'
);
}
//
// to check if a string only contains US-ASCII code point
...
...
test/java/net/IDN/IllegalArg.java
0 → 100644
浏览文件 @
4ac0465e
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8020842
* @summary IDN do not throw IAE when hostname ends with a trailing dot
*/
import
java.net.*
;
public
class
IllegalArg
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
[]
illegalNames
=
{
"com..net"
,
"com.."
,
".com"
,
".com."
};
String
[]
legalNames
=
{
"example.com"
,
"com\u3002"
,
"com."
,
"."
};
for
(
String
name
:
illegalNames
)
{
try
{
IDN
.
toASCII
(
name
,
IDN
.
USE_STD3_ASCII_RULES
);
throw
new
Exception
(
"Expected to get IllegalArgumentException for "
+
name
);
}
catch
(
IllegalArgumentException
iae
)
{
// That's the right behavior.
}
try
{
IDN
.
toASCII
(
name
);
throw
new
Exception
(
"Expected to get IllegalArgumentException for "
+
name
);
}
catch
(
IllegalArgumentException
iae
)
{
// That's the right behavior.
}
}
for
(
String
name
:
legalNames
)
{
System
.
out
.
println
(
"Convering "
+
name
);
System
.
out
.
println
(
IDN
.
toASCII
(
name
,
IDN
.
USE_STD3_ASCII_RULES
));
}
}
}
test/sun/security/ssl/javax/net/ssl/ServerName/IllegalSNIName.java
0 → 100644
浏览文件 @
4ac0465e
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8020842
* @summary SNIHostName does not throw IAE when hostname ends
* with a trailing dot
*/
import
javax.net.ssl.SNIHostName
;
public
class
IllegalSNIName
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
[]
illegalNames
=
{
"example\u3003\u3002com"
,
"example..com"
,
"com\u3002"
,
"com."
,
"."
};
for
(
String
name
:
illegalNames
)
{
try
{
SNIHostName
hostname
=
new
SNIHostName
(
name
);
throw
new
Exception
(
"Expected to get IllegalArgumentException for "
+
name
);
}
catch
(
IllegalArgumentException
iae
)
{
// That's the right behavior.
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录