Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
6f34b357
Commit
6f34b357
authored
Jul 15, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert_xml_special_chars: factor
parent
89d3524d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
34 deletions
+23
-34
src/text/strings.c
src/text/strings.c
+23
-34
No files found.
src/text/strings.c
View file @
6f34b357
...
@@ -402,47 +402,36 @@ void resolve_xml_special_chars( char *psz_value )
...
@@ -402,47 +402,36 @@ void resolve_xml_special_chars( char *psz_value )
*/
*/
char
*
convert_xml_special_chars
(
const
char
*
psz_content
)
char
*
convert_xml_special_chars
(
const
char
*
psz_content
)
{
{
char
*
psz_temp
=
malloc
(
6
*
strlen
(
psz_content
)
+
1
);
assert
(
psz_content
);
const
char
*
p_from
=
psz_content
;
const
size_t
len
=
strlen
(
psz_content
);
char
*
const
psz_temp
=
malloc
(
6
*
len
+
1
);
char
*
p_to
=
psz_temp
;
char
*
p_to
=
psz_temp
;
while
(
*
p_from
)
if
(
psz_temp
==
NULL
)
{
return
NULL
;
if
(
*
p_from
==
'<'
)
for
(
size_t
i
=
0
;
i
<
len
;
i
++
)
{
strcpy
(
p_to
,
"<"
);
p_to
+=
4
;
}
else
if
(
*
p_from
==
'>'
)
{
strcpy
(
p_to
,
">"
);
p_to
+=
4
;
}
else
if
(
*
p_from
==
'&'
)
{
strcpy
(
p_to
,
"&"
);
p_to
+=
5
;
}
else
if
(
*
p_from
==
'\"'
)
{
strcpy
(
p_to
,
"""
);
p_to
+=
6
;
}
else
if
(
*
p_from
==
'\''
)
{
{
strcpy
(
p_to
,
"'"
)
;
const
char
*
str
;
p_to
+=
6
;
char
c
=
psz_content
[
i
]
;
}
else
switch
(
c
)
{
{
*
p_to
=
*
p_from
;
case
'\"'
:
str
=
"quot"
;
break
;
p_to
++
;
case
'&'
:
str
=
"amp"
;
break
;
case
'\''
:
str
=
"#39"
;
break
;
case
'<'
:
str
=
"lt"
;
break
;
case
'>'
:
str
=
"gt"
;
break
;
default:
*
(
p_to
++
)
=
c
;
continue
;
}
}
p_
from
++
;
p_
to
+=
sprintf
(
p_to
,
"&%s;"
,
str
)
;
}
}
*
p_to
=
'\0'
;
*
(
p_to
++
)
=
'\0'
;
return
psz_temp
;
p_to
=
realloc
(
psz_temp
,
p_to
-
psz_temp
);
return
p_to
?
p_to
:
psz_temp
;
/* cannot fail */
}
}
/* Base64 encoding */
/* Base64 encoding */
...
...
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