pidgin/pidgin
Clone
Summary
Browse
Changes
Graph
Enable structured logging in Pidgin
2021-10-18, Elliott Sales de Andrade
dff0811ff40c
Enable structured logging in Pidgin
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/1068/
/*
* Purple - Internet Messaging Library
* Copyright (C) Pidgin Developers <devel@pidgin.im>
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#include
<glib.h>
#include
<purple.h>
typedef
struct
{
gchar
*
markup
;
gchar
*
xhtml
;
gchar
*
plaintext
;
}
MarkupTestData
;
static
void
test_util_markup_html_to_xhtml
(
void
)
{
gint
i
;
MarkupTestData
data
[]
=
{
{
"<a>"
,
"<a href=
\"\"
></a>"
,
""
,
},
{
"<A href='URL'>ABOUT</a>"
,
"<a href=
\"
URL
\"
>ABOUT</a>"
,
"ABOUT <URL>"
,
},
{
"<a href='URL'>URL</a>"
,
"<a href=
\"
URL
\"
>URL</a>"
,
"URL"
,
},
{
"<a href='mailto:mail'>mail</a>"
,
"<a href=
\"
mailto:mail
\"
>mail</a>"
,
"mail"
,
},
{
"<A href='
\"
U'R&L'>ABOUT</a>"
,
"<a href=
\"
"U'R&L
\"
>ABOUT</a>"
,
"ABOUT <
\"
U'R&L>"
,
},
{
"<img src='SRC' alt='ALT'/>"
,
"<img src='SRC' alt='ALT' />"
,
"ALT"
,
},
{
"<img src=
\"
'S'R&C
\"
alt=
\"
'A'L&T
\"
/>"
,
"<img src=''S'R&C' alt=''A'L&T' />"
,
"'A'L&T"
,
},
{
"<unknown>"
,
"<unknown>"
,
"<unknown>"
,
},
{
"é&"
,
"é&"
,
"é&"
,
},
{
"<h1>A<h2>B</h2>C</h1>"
,
"<h1>A<h2>B</h2>C</h1>"
,
"ABC"
,
},
{
"<h1><h2><h3><h4>"
,
"<h1><h2><h3><h4></h4></h3></h2></h1>"
,
""
,
},
{
"<italic/>"
,
"<em/>"
,
""
,
},
{
"</"
,
"</"
,
"</"
,
},
{
"</div>"
,
""
,
""
,
},
{
"<hr/>"
,
"<br/>"
,
"
\n
"
,
},
{
"<hr>"
,
"<br/>"
,
"
\n
"
,
},
{
"<br />"
,
"<br/>"
,
"
\n
"
,
},
{
"<br>INSIDE</br>"
,
"<br/>INSIDE"
,
"
\n
INSIDE"
,
},
{
"<div></div>"
,
"<div></div>"
,
""
,
},
{
"<div/>"
,
"<div/>"
,
""
,
},
{
"<div attr='
\"
&<>'/>"
,
"<div attr='"&<>'/>"
,
""
,
},
{
"<div attr=
\"
'
\"
/>"
,
"<div attr=
\"
'
\"
/>"
,
""
,
},
{
"<div/> < <div/>"
,
"<div/> < <div/>"
,
" < "
,
},
{
"<div>x</div>"
,
"<div>x</div>"
,
"x"
,
},
{
"<b>x</b>"
,
"<span style='font-weight: bold;'>x</span>"
,
"x"
,
},
{
"<bold>x</bold>"
,
"<span style='font-weight: bold;'>x</span>"
,
"x"
,
},
{
"<strong>x</strong>"
,
"<span style='font-weight: bold;'>x</span>"
,
"x"
,
},
{
"<u>x</u>"
,
"<span style='text-decoration: underline;'>x</span>"
,
"x"
,
},
{
"<underline>x</underline>"
,
"<span style='text-decoration: underline;'>x</span>"
,
"x"
,
},
{
"<s>x</s>"
,
"<span style='text-decoration: line-through;'>x</span>"
,
"x"
,
},
{
"<strike>x</strike>"
,
"<span style='text-decoration: line-through;'>x</span>"
,
"x"
,
},
{
"<sub>x</sub>"
,
"<span style='vertical-align:sub;'>x</span>"
,
"x"
,
},
{
"<sup>x</sup>"
,
"<span style='vertical-align:super;'>x</span>"
,
"x"
,
},
{
"<FONT>x</FONT>"
,
"x"
,
"x"
,
},
{
"<font face=
\"
'Times>New & Roman'
\"
>x</font>"
,
"<span style='font-family:
\"
Times>New & Roman
\"
;'>x</span>"
,
"x"
,
},
{
"<font back=
\"
'color>blue&red'
\"
>x</font>"
,
"<span style='background:
\"
color>blue&red
\"
;'>x</span>"
,
"x"
,
},
{
"<font color=
\"
'color>blue&red'
\"
>x</font>"
,
"<span style='color:
\"
color>blue&red
\"
;'>x</span>"
,
"x"
,
},
{
"<font size=1>x</font>"
,
"<span style='font-size: xx-small;'>x</span>"
,
"x"
,
},
{
"<font size=432>x</font>"
,
"<span style='font-size: medium;'>x</span>"
,
"x"
,
},
{
"<!--COMMENT-->"
,
"<!--COMMENT-->"
,
"COMMENT-->"
,
},
{
"<br />"
,
"<br />"
,
"<br />"
,
},
{
"<hr />"
,
"<hr />"
,
"<hr />"
},
{
NULL
,
NULL
,
NULL
,
}
};
for
(
i
=
0
;
data
[
i
].
markup
;
i
++
)
{
gchar
*
xhtml
=
NULL
,
*
plaintext
=
NULL
;
purple_markup_html_to_xhtml
(
data
[
i
].
markup
,
&
xhtml
,
&
plaintext
);
g_assert_cmpstr
(
data
[
i
].
xhtml
,
==
,
xhtml
);
g_free
(
xhtml
);
g_assert_cmpstr
(
data
[
i
].
plaintext
,
==
,
plaintext
);
g_free
(
plaintext
);
}
}
/******************************************************************************
* Main
*****************************************************************************/
gint
main
(
gint
argc
,
gchar
**
argv
)
{
g_test_init
(
&
argc
,
&
argv
,
NULL
);
g_test_add_func
(
"/util/markup/html to xhtml"
,
test_util_markup_html_to_xhtml
);
return
g_test_run
();
}