Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party CJSON
提交
52d7d14f
T
Third Party CJSON
项目概览
OpenHarmony
/
Third Party CJSON
大约 1 年 前同步成功
通知
6
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party CJSON
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52d7d14f
编写于
3月 06, 2016
作者:
C
Christian Schulze
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed segfault when the lib tries to parse HTML with embedded CSS; provided test case
上级
e70366a6
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
37 addition
and
2 deletion
+37
-2
cJSON.c
cJSON.c
+2
-2
test.c
test.c
+19
-0
tests/test6
tests/test6
+16
-0
未找到文件。
cJSON.c
浏览文件 @
52d7d14f
...
@@ -660,8 +660,8 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
...
@@ -660,8 +660,8 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
/* Get Array size/item / object item. */
/* Get Array size/item / object item. */
int
cJSON_GetArraySize
(
cJSON
*
array
)
{
cJSON
*
c
=
array
->
child
;
int
i
=
0
;
while
(
c
)
i
++
,
c
=
c
->
next
;
return
i
;}
int
cJSON_GetArraySize
(
cJSON
*
array
)
{
cJSON
*
c
=
array
->
child
;
int
i
=
0
;
while
(
c
)
i
++
,
c
=
c
->
next
;
return
i
;}
cJSON
*
cJSON_GetArrayItem
(
cJSON
*
array
,
int
item
)
{
cJSON
*
c
=
array
->
child
;
while
(
c
&&
item
>
0
)
item
--
,
c
=
c
->
next
;
return
c
;}
cJSON
*
cJSON_GetArrayItem
(
cJSON
*
array
,
int
item
)
{
cJSON
*
c
;
if
(
array
==
NULL
)
return
NULL
;
c
=
array
->
child
;
while
(
c
&&
item
>
0
)
item
--
,
c
=
c
->
next
;
return
c
;}
cJSON
*
cJSON_GetObjectItem
(
cJSON
*
object
,
const
char
*
string
)
{
cJSON
*
c
=
object
->
child
;
while
(
c
&&
cJSON_strcasecmp
(
c
->
string
,
string
))
c
=
c
->
next
;
return
c
;}
cJSON
*
cJSON_GetObjectItem
(
cJSON
*
object
,
const
char
*
string
)
{
cJSON
*
c
;
if
(
object
==
NULL
)
return
NULL
;
c
=
object
->
child
;
while
(
c
&&
cJSON_strcasecmp
(
c
->
string
,
string
))
c
=
c
->
next
;
return
c
;}
int
cJSON_HasObjectItem
(
cJSON
*
object
,
const
char
*
string
)
{
int
cJSON_HasObjectItem
(
cJSON
*
object
,
const
char
*
string
)
{
cJSON
*
c
=
object
->
child
;
cJSON
*
c
=
object
->
child
;
while
(
c
)
while
(
c
)
...
...
test.c
浏览文件 @
52d7d14f
...
@@ -144,12 +144,30 @@ int main (int argc, const char * argv[]) {
...
@@ -144,12 +144,30 @@ int main (int argc, const char * argv[]) {
char
text4
[]
=
"{
\n
\"
Image
\"
: {
\n
\"
Width
\"
: 800,
\n
\"
Height
\"
: 600,
\n
\"
Title
\"
:
\"
View from 15th Floor
\"
,
\n
\"
Thumbnail
\"
: {
\n
\"
Url
\"
:
\"
http:/*www.example.com/image/481989943
\"
,
\n
\"
Height
\"
: 125,
\n
\"
Width
\"
:
\"
100
\"\n
},
\n
\"
IDs
\"
: [116, 943, 234, 38793]
\n
}
\n
}"
;
char
text4
[]
=
"{
\n
\"
Image
\"
: {
\n
\"
Width
\"
: 800,
\n
\"
Height
\"
: 600,
\n
\"
Title
\"
:
\"
View from 15th Floor
\"
,
\n
\"
Thumbnail
\"
: {
\n
\"
Url
\"
:
\"
http:/*www.example.com/image/481989943
\"
,
\n
\"
Height
\"
: 125,
\n
\"
Width
\"
:
\"
100
\"\n
},
\n
\"
IDs
\"
: [116, 943, 234, 38793]
\n
}
\n
}"
;
char
text5
[]
=
"[
\n
{
\n
\"
precision
\"
:
\"
zip
\"
,
\n
\"
Latitude
\"
: 37.7668,
\n
\"
Longitude
\"
: -122.3959,
\n
\"
Address
\"
:
\"\"
,
\n
\"
City
\"
:
\"
SAN FRANCISCO
\"
,
\n
\"
State
\"
:
\"
CA
\"
,
\n
\"
Zip
\"
:
\"
94107
\"
,
\n
\"
Country
\"
:
\"
US
\"\n
},
\n
{
\n
\"
precision
\"
:
\"
zip
\"
,
\n
\"
Latitude
\"
: 37.371991,
\n
\"
Longitude
\"
: -122.026020,
\n
\"
Address
\"
:
\"\"
,
\n
\"
City
\"
:
\"
SUNNYVALE
\"
,
\n
\"
State
\"
:
\"
CA
\"
,
\n
\"
Zip
\"
:
\"
94085
\"
,
\n
\"
Country
\"
:
\"
US
\"\n
}
\n
]"
;
char
text5
[]
=
"[
\n
{
\n
\"
precision
\"
:
\"
zip
\"
,
\n
\"
Latitude
\"
: 37.7668,
\n
\"
Longitude
\"
: -122.3959,
\n
\"
Address
\"
:
\"\"
,
\n
\"
City
\"
:
\"
SAN FRANCISCO
\"
,
\n
\"
State
\"
:
\"
CA
\"
,
\n
\"
Zip
\"
:
\"
94107
\"
,
\n
\"
Country
\"
:
\"
US
\"\n
},
\n
{
\n
\"
precision
\"
:
\"
zip
\"
,
\n
\"
Latitude
\"
: 37.371991,
\n
\"
Longitude
\"
: -122.026020,
\n
\"
Address
\"
:
\"\"
,
\n
\"
City
\"
:
\"
SUNNYVALE
\"
,
\n
\"
State
\"
:
\"
CA
\"
,
\n
\"
Zip
\"
:
\"
94085
\"
,
\n
\"
Country
\"
:
\"
US
\"\n
}
\n
]"
;
char
text6
[]
=
"<!DOCTYPE html>"
"<html>
\n
"
"<head>
\n
"
" <meta name=
\"
viewport
\"
content=
\"
width=device-width, initial-scale=1
\"
>
\n
"
" <style type=
\"
text/css
\"
>
\n
"
" html, body, iframe { margin: 0; padding: 0; height: 100%; }
\n
"
" iframe { display: block; width: 100%; border: none; }
\n
"
" </style>
\n
"
"<title>Application Error</title>
\n
"
"</head>
\n
"
"<body>
\n
"
" <iframe src="
//s3.amazonaws.com/heroku_pages/error.html">\n"
" <p>Application Error</p>
\n
"
" </iframe>
\n
"
"</body>
\n
"
"</html>
\n
"
;
/* Process each json textblock by parsing, then rebuilding: */
/* Process each json textblock by parsing, then rebuilding: */
doit
(
text1
);
doit
(
text1
);
doit
(
text2
);
doit
(
text2
);
doit
(
text3
);
doit
(
text3
);
doit
(
text4
);
doit
(
text4
);
doit
(
text5
);
doit
(
text5
);
doit
(
text6
);
/* Parse standard testfiles: */
/* Parse standard testfiles: */
/* dofile("../../tests/test1"); */
/* dofile("../../tests/test1"); */
...
@@ -157,6 +175,7 @@ int main (int argc, const char * argv[]) {
...
@@ -157,6 +175,7 @@ int main (int argc, const char * argv[]) {
/* dofile("../../tests/test3"); */
/* dofile("../../tests/test3"); */
/* dofile("../../tests/test4"); */
/* dofile("../../tests/test4"); */
/* dofile("../../tests/test5"); */
/* dofile("../../tests/test5"); */
/* dofile("../../tests/test6"); */
/* Now some samplecode for building objects concisely: */
/* Now some samplecode for building objects concisely: */
create_objects
();
create_objects
();
...
...
tests/test6
0 → 100644
浏览文件 @
52d7d14f
<!DOCTYPE html>
<html>
<head>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<style
type=
"text/css"
>
html
,
body
,
iframe
{
margin
:
0
;
padding
:
0
;
height
:
100%
;
}
iframe
{
display
:
block
;
width
:
100%
;
border
:
none
;
}
</style>
<title>
Application Error
</title>
</head>
<body>
<iframe
src=
"//s3.amazonaws.com/heroku_pages/error.html"
>
<p>
Application Error
</p>
</iframe>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录