Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
e634fed4
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e634fed4
编写于
7月 16, 2014
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[buffer] Validate UTF-32 input
Same as what we do for UTF-8 and UTF-16.
上级
b98c5db3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
3 deletion
+65
-3
src/hb-utf-private.hh
src/hb-utf-private.hh
+10
-3
test/api/test-buffer.c
test/api/test-buffer.c
+55
-0
未找到文件。
src/hb-utf-private.hh
浏览文件 @
e634fed4
...
...
@@ -198,7 +198,14 @@ hb_utf_next (const uint32_t *text,
const
uint32_t
*
end
HB_UNUSED
,
hb_codepoint_t
*
unicode
)
{
*
unicode
=
*
text
++
;
hb_codepoint_t
c
=
*
text
++
;
if
(
unlikely
(
c
>
0x10FFFFu
||
hb_in_range
(
c
,
0xD800u
,
0xDFFFu
)))
goto
error
;
*
unicode
=
c
;
return
text
;
error:
*
unicode
=
-
1
;
return
text
;
}
...
...
@@ -207,8 +214,8 @@ hb_utf_prev (const uint32_t *text,
const
uint32_t
*
start
HB_UNUSED
,
hb_codepoint_t
*
unicode
)
{
*
unicode
=
*--
text
;
return
text
;
hb_utf_next
(
text
-
1
,
text
,
unicode
)
;
return
text
-
1
;
}
static
inline
unsigned
int
...
...
test/api/test-buffer.c
浏览文件 @
e634fed4
...
...
@@ -744,6 +744,60 @@ test_buffer_utf16_conversion (void)
hb_buffer_destroy
(
b
);
}
typedef
struct
{
const
uint32_t
utf32
[
8
];
const
uint32_t
codepoints
[
8
];
}
utf32_conversion_test_t
;
/* note: we skip the first and last item from utf32 when adding to buffer */
static
const
utf32_conversion_test_t
utf32_conversion_tests
[]
=
{
{{
0x41
,
0x004D
,
0x0430
,
0x4E8C
,
0xD800
,
0xDF02
,
0x61
}
,
{
0x004D
,
0x0430
,
0x4E8C
,
-
1
,
-
1
}},
{{
0x41
,
0x004D
,
0x0430
,
0x4E8C
,
0x10302
,
0x61
}
,
{
0x004D
,
0x0430
,
0x4E8C
,
0x10302
}},
{{
0x41
,
0xD800
,
0xDF02
,
0x61
},
{
-
1
,
-
1
}},
{{
0x41
,
0xD800
,
0xDF02
},
{
-
1
}},
{{
0x41
,
0x61
,
0xD800
,
0xDF02
},
{
0x61
,
-
1
}},
{{
0x41
,
0xD800
,
0x61
,
0xDF02
},
{
-
1
,
0x61
}},
{{
0x41
,
0xDF00
,
0x61
},
{
-
1
}},
{{
0x41
,
0x10FFFF
,
0x61
},
{
0x10FFFF
}},
{{
0x41
,
0x110000
,
0x61
},
{
-
1
}},
{{
0x41
,
0x61
},
{
0
}}
};
static
void
test_buffer_utf32_conversion
(
void
)
{
hb_buffer_t
*
b
;
unsigned
int
i
;
b
=
hb_buffer_create
();
for
(
i
=
0
;
i
<
G_N_ELEMENTS
(
utf32_conversion_tests
);
i
++
)
{
const
utf32_conversion_test_t
*
test
=
&
utf32_conversion_tests
[
i
];
unsigned
int
u_len
,
chars
,
j
,
len
;
hb_glyph_info_t
*
glyphs
;
g_test_message
(
"UTF-32 test #%d"
,
i
);
for
(
u_len
=
0
;
test
->
utf32
[
u_len
];
u_len
++
)
;
for
(
chars
=
0
;
test
->
codepoints
[
chars
];
chars
++
)
;
hb_buffer_reset
(
b
);
hb_buffer_add_utf32
(
b
,
test
->
utf32
,
u_len
,
1
,
u_len
-
2
);
glyphs
=
hb_buffer_get_glyph_infos
(
b
,
&
len
);
g_assert_cmpint
(
len
,
==
,
chars
);
for
(
j
=
0
;
j
<
chars
;
j
++
)
g_assert_cmphex
(
glyphs
[
j
].
codepoint
,
==
,
test
->
codepoints
[
j
]);
}
hb_buffer_destroy
(
b
);
}
static
void
test_empty
(
hb_buffer_t
*
b
)
{
...
...
@@ -810,6 +864,7 @@ main (int argc, char **argv)
hb_test_add
(
test_buffer_utf8_conversion
);
hb_test_add
(
test_buffer_utf8_validity
);
hb_test_add
(
test_buffer_utf16_conversion
);
hb_test_add
(
test_buffer_utf32_conversion
);
hb_test_add
(
test_buffer_empty
);
return
hb_test_run
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录