Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwn
libplist
Commits
009c5038
Commit
009c5038
authored
Nov 13, 2016
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xplist: Support converting numerical character entities
parent
3a92084e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
3 deletions
+51
-3
xplist.c
src/xplist.c
+51
-3
No files found.
src/xplist.c
View file @
009c5038
...
...
@@ -518,7 +518,7 @@ static char* get_text_content(parse_ctx ctx, const char* tag, int skip_ws, int u
if
(
i
>=
len
)
{
break
;
}
if
(
str
+
i
>
entp
+
1
)
{
if
(
str
+
i
>
=
entp
+
1
)
{
int
entlen
=
str
+
i
-
entp
;
if
(
!
strncmp
(
entp
,
"amp"
,
3
))
{
/* the '&' is already there */
...
...
@@ -530,9 +530,57 @@ static char* get_text_content(parse_ctx ctx, const char* tag, int skip_ws, int u
*
(
entp
-
1
)
=
'<'
;
}
else
if
(
!
strncmp
(
entp
,
"gt"
,
2
))
{
*
(
entp
-
1
)
=
'>'
;
}
else
if
(
*
entp
==
'#'
)
{
/* numerical character reference */
uint64_t
val
=
0
;
char
*
ep
=
NULL
;
if
(
entlen
>
8
)
{
PLIST_XML_ERR
(
"Invalid numerical character reference encountered, sequence too long: &%.*s;
\n
"
,
entlen
,
entp
);
return
NULL
;
}
if
(
*
(
entp
+
1
)
==
'x'
||
*
(
entp
+
1
)
==
'X'
)
{
if
(
entlen
<
3
)
{
PLIST_XML_ERR
(
"Invalid numerical character reference encountered, sequence too short: &%.*s;
\n
"
,
entlen
,
entp
);
return
NULL
;
}
val
=
strtoull
(
entp
+
2
,
&
ep
,
16
);
}
else
{
if
(
entlen
<
2
)
{
PLIST_XML_ERR
(
"Invalid numerical character reference encountered, sequence too short: &%.*s;
\n
"
,
entlen
,
entp
);
return
NULL
;
}
val
=
strtoull
(
entp
+
1
,
&
ep
,
10
);
}
if
(
val
==
0
||
val
>
0x10FFFF
||
ep
-
entp
!=
entlen
)
{
PLIST_XML_ERR
(
"Invalid numerical character reference found: &%.*s;
\n
"
,
entlen
,
entp
);
return
NULL
;
}
/* convert to UTF8 */
if
(
val
>=
0x10000
)
{
/* four bytes */
*
(
entp
-
1
)
=
(
char
)(
0xF0
+
((
val
>>
18
)
&
0x7
));
*
(
entp
+
0
)
=
(
char
)(
0x80
+
((
val
>>
12
)
&
0x3F
));
*
(
entp
+
1
)
=
(
char
)(
0x80
+
((
val
>>
6
)
&
0x3F
));
*
(
entp
+
2
)
=
(
char
)(
0x80
+
(
val
&
0x3F
));
entp
+=
3
;
}
else
if
(
val
>=
0x800
)
{
/* three bytes */
*
(
entp
-
1
)
=
(
char
)(
0xE0
+
((
val
>>
12
)
&
0xF
));
*
(
entp
+
0
)
=
(
char
)(
0x80
+
((
val
>>
6
)
&
0x3F
));
*
(
entp
+
1
)
=
(
char
)(
0x80
+
(
val
&
0x3F
));
entp
+=
2
;
}
else
if
(
val
>=
0x80
)
{
/* two bytes */
*
(
entp
-
1
)
=
(
char
)(
0xC0
+
((
val
>>
6
)
&
0x1F
));
*
(
entp
+
0
)
=
(
char
)(
0x80
+
(
val
&
0x3F
));
entp
++
;
}
else
{
/* unexpected entity, replace with ? */
*
(
entp
-
1
)
=
'?'
;
/* one byte */
*
(
entp
-
1
)
=
(
char
)(
val
&
0x7F
);
}
}
else
{
PLIST_XML_ERR
(
"Invalid entity encountered: &%.*s;
\n
"
,
entlen
,
entp
);
return
NULL
;
}
memmove
(
entp
,
str
+
i
+
1
,
len
-
i
);
i
-=
entlen
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment