Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
99
Issues
99
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
7d8ce3b5
Commit
7d8ce3b5
authored
Dec 11, 2013
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use XML-sanitized strings when serializing stanzas for the XMPP server
parent
3960e4d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
src/test.cpp
src/test.cpp
+8
-0
src/xmpp/xmpp_stanza.cpp
src/xmpp/xmpp_stanza.cpp
+4
-3
No files found.
src/test.cpp
View file @
7d8ce3b5
...
...
@@ -97,6 +97,14 @@ int main()
});
xml
.
feed
(
doc
.
data
(),
doc
.
size
(),
true
);
const
std
::
string
doc2
=
"<stream xmlns='s'><stanza>coucou
\r\n\a
</stanza></stream>"
;
xml
.
add_stanza_callback
([](
const
Stanza
&
stanza
)
{
std
::
cout
<<
stanza
.
to_string
()
<<
std
::
endl
;
assert
(
stanza
.
get_inner
()
==
"coucou
\r\n
"
);
});
xml
.
feed
(
doc2
.
data
(),
doc
.
size
(),
true
);
/**
* XML escape/escape
*/
...
...
src/xmpp/xmpp_stanza.cpp
View file @
7d8ce3b5
...
...
@@ -192,12 +192,13 @@ std::string XmlNode::to_string() const
std
::
string
res
(
"<"
);
res
+=
this
->
name
;
for
(
const
auto
&
it
:
this
->
attributes
)
res
+=
" "
+
it
.
first
+
"='"
+
it
.
second
+
"'"
;
res
+=
" "
+
utils
::
remove_invalid_xml_chars
(
it
.
first
)
+
"='"
+
utils
::
remove_invalid_xml_chars
(
it
.
second
)
+
"'"
;
if
(
this
->
closed
&&
!
this
->
has_children
()
&&
this
->
inner
.
empty
())
res
+=
"/>"
;
else
{
res
+=
">"
+
this
->
inner
;
res
+=
">"
+
utils
::
remove_invalid_xml_chars
(
this
->
inner
)
;
for
(
const
auto
&
child
:
this
->
children
)
res
+=
child
->
to_string
();
if
(
this
->
closed
)
...
...
@@ -205,7 +206,7 @@ std::string XmlNode::to_string() const
res
+=
"</"
+
this
->
name
+
">"
;
}
}
res
+=
this
->
tail
;
res
+=
utils
::
remove_invalid_xml_chars
(
this
->
tail
)
;
return
res
;
}
...
...
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