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
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
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
2be4811d
Commit
2be4811d
authored
Nov 11, 2013
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unescape XML before sending messages over IRC
parent
096a4e3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
src/xmpp/xmpp_stanza.cpp
src/xmpp/xmpp_stanza.cpp
+47
-2
src/xmpp/xmpp_stanza.hpp
src/xmpp/xmpp_stanza.hpp
+1
-1
No files found.
src/xmpp/xmpp_stanza.cpp
View file @
2be4811d
...
...
@@ -4,6 +4,8 @@
#include <iostream>
#include <string.h>
std
::
string
xml_escape
(
const
std
::
string
&
data
)
{
std
::
string
res
;
...
...
@@ -35,6 +37,49 @@ std::string xml_escape(const std::string& data)
return
res
;
}
std
::
string
xml_unescape
(
const
std
::
string
&
data
)
{
std
::
string
res
;
res
.
reserve
(
data
.
size
());
const
char
*
str
=
data
.
c_str
();
while
(
str
&&
*
str
&&
(
str
-
data
.
c_str
())
<
data
.
size
())
{
if
(
*
str
==
'&'
)
{
if
(
strncmp
(
str
+
1
,
"amp;"
,
4
)
==
0
)
{
res
+=
"&"
;
str
+=
4
;
}
else
if
(
strncmp
(
str
+
1
,
"lt;"
,
3
)
==
0
)
{
res
+=
"<"
;
str
+=
3
;
}
else
if
(
strncmp
(
str
+
1
,
"gt;"
,
3
)
==
0
)
{
res
+=
">"
;
str
+=
3
;
}
else
if
(
strncmp
(
str
+
1
,
"quot;"
,
5
)
==
0
)
{
res
+=
"
\"
"
;
str
+=
5
;
}
else
if
(
strncmp
(
str
+
1
,
"apos;"
,
5
)
==
0
)
{
res
+=
"'"
;
str
+=
5
;
}
else
res
+=
"&"
;
}
else
res
+=
*
str
;
str
++
;
}
return
res
;
}
XmlNode
::
XmlNode
(
const
std
::
string
&
name
,
XmlNode
*
parent
)
:
name
(
name
),
...
...
@@ -89,12 +134,12 @@ void XmlNode::add_to_inner(const std::string& data)
std
::
string
XmlNode
::
get_inner
()
const
{
return
this
->
inner
;
return
xml_unescape
(
this
->
inner
)
;
}
std
::
string
XmlNode
::
get_tail
()
const
{
return
this
->
tail
;
return
xml_unescape
(
this
->
tail
)
;
}
XmlNode
*
XmlNode
::
get_child
(
const
std
::
string
&
name
)
const
...
...
src/xmpp/xmpp_stanza.hpp
View file @
2be4811d
...
...
@@ -6,6 +6,7 @@
#include <vector>
std
::
string
xml_escape
(
const
std
::
string
&
data
);
std
::
string
xml_unescape
(
const
std
::
string
&
data
);
/**
* Raised on operator[] when the attribute does not exist
...
...
@@ -66,7 +67,6 @@ public:
void
add_to_inner
(
const
std
::
string
&
data
);
/**
* Get the content of inner
* TODO: unescape it here.
*/
std
::
string
get_inner
()
const
;
/**
...
...
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