Thu, 23 Jan 2014 23:38:47 -0800
Merge release-2.x.y branch into main, with manual merges in
ChangeLog (easy)
Makefile.mingw (easy)
configure.ac (easy)
irc/msgs.c (not too bad)
And some Windows build files. We should make sure the pango used by 3.0.0
doesn't have the crash bug from CVE-2013-6486.
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
1 | #include <string.h> |
|
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
2 | |
| 15104 | 3 | #include "tests.h" |
| 4 | #include "../util.h" | |
| 5 | ||
| 6 | START_TEST(test_util_base16_encode) | |
| 7 | { | |
|
26553
a1417d5cdedb
Cast away a few compile warnings in our "make check" tests, and add
Mark Doliner <markdoliner@pidgin.im>
parents:
22321
diff
changeset
|
8 | assert_string_equal_free("68656c6c6f2c20776f726c642100", purple_base16_encode((const unsigned char *)"hello, world!", 14)); |
| 15104 | 9 | } |
| 10 | END_TEST | |
| 11 | ||
| 12 | START_TEST(test_util_base16_decode) | |
| 13 | { | |
| 14 | gsize sz = 0; | |
| 15884 | 15 | guchar *out = purple_base16_decode("21646c726f77202c6f6c6c656800", &sz); |
| 15104 | 16 | fail_unless(sz == 14, NULL); |
|
27709
4bb974aef0b7
Use assert_string_equal_free() instead of just assert_string_equal()
Mark Doliner <markdoliner@pidgin.im>
parents:
27481
diff
changeset
|
17 | assert_string_equal_free("!dlrow ,olleh", (char *)out); |
| 15104 | 18 | } |
| 19 | END_TEST | |
| 20 | ||
| 21 | START_TEST(test_util_base64_encode) | |
| 22 | { | |
|
26553
a1417d5cdedb
Cast away a few compile warnings in our "make check" tests, and add
Mark Doliner <markdoliner@pidgin.im>
parents:
22321
diff
changeset
|
23 | assert_string_equal_free("Zm9ydHktdHdvAA==", purple_base64_encode((const unsigned char *)"forty-two", 10)); |
| 15104 | 24 | } |
| 25 | END_TEST | |
| 26 | ||
| 27 | START_TEST(test_util_base64_decode) | |
| 28 | { | |
| 29 | gsize sz; | |
| 15884 | 30 | guchar *out = purple_base64_decode("b3d0LXl0cm9mAA==", &sz); |
| 15104 | 31 | fail_unless(sz == 10, NULL); |
|
27709
4bb974aef0b7
Use assert_string_equal_free() instead of just assert_string_equal()
Mark Doliner <markdoliner@pidgin.im>
parents:
27481
diff
changeset
|
32 | assert_string_equal_free("owt-ytrof", (char *)out); |
| 15104 | 33 | } |
| 34 | END_TEST | |
| 35 | ||
| 36 | START_TEST(test_util_escape_filename) | |
| 37 | { | |
| 15884 | 38 | assert_string_equal("foo", purple_escape_filename("foo")); |
| 39 | assert_string_equal("@oo", purple_escape_filename("@oo")); | |
| 40 | assert_string_equal("#oo", purple_escape_filename("#oo")); | |
| 41 | assert_string_equal("-oo", purple_escape_filename("-oo")); | |
| 42 | assert_string_equal("_oo", purple_escape_filename("_oo")); | |
| 43 | assert_string_equal(".oo", purple_escape_filename(".oo")); | |
| 44 | assert_string_equal("%25oo", purple_escape_filename("%oo")); | |
| 45 | assert_string_equal("%21oo", purple_escape_filename("!oo")); | |
| 15104 | 46 | } |
| 47 | END_TEST | |
| 48 | ||
| 49 | START_TEST(test_util_unescape_filename) | |
| 50 | { | |
| 15884 | 51 | assert_string_equal("bar", purple_unescape_filename("bar")); |
| 52 | assert_string_equal("@ar", purple_unescape_filename("@ar")); | |
| 53 | assert_string_equal("!ar", purple_unescape_filename("!ar")); | |
| 54 | assert_string_equal("!ar", purple_unescape_filename("%21ar")); | |
| 55 | assert_string_equal("%ar", purple_unescape_filename("%25ar")); | |
| 15104 | 56 | } |
| 57 | END_TEST | |
| 58 | ||
| 59 | ||
| 60 | START_TEST(test_util_text_strip_mnemonic) | |
| 61 | { | |
| 15884 | 62 | assert_string_equal_free("", purple_text_strip_mnemonic("")); |
| 63 | assert_string_equal_free("foo", purple_text_strip_mnemonic("foo")); | |
| 64 | assert_string_equal_free("foo", purple_text_strip_mnemonic("_foo")); | |
| 15104 | 65 | |
| 66 | } | |
| 67 | END_TEST | |
| 68 | ||
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
69 | /* |
|
30442
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
70 | * Many of the valid and invalid email addresses lised below are from |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
71 | * http://fightingforalostcause.net/misc/2006/compare-email-regex.php |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
72 | */ |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
73 | const char *valid_emails[] = { |
|
30442
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
74 | "purple-devel@lists.sf.net", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
75 | "l3tt3rsAndNumb3rs@domain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
76 | "has-dash@domain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
77 | "hasApostrophe.o'leary@domain.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
78 | "uncommonTLD@domain.museum", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
79 | "uncommonTLD@domain.travel", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
80 | "uncommonTLD@domain.mobi", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
81 | "countryCodeTLD@domain.uk", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
82 | "countryCodeTLD@domain.rw", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
83 | "lettersInDomain@911.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
84 | "underscore_inLocal@domain.net", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
85 | "IPInsteadOfDomain@127.0.0.1", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
86 | /* "IPAndPort@127.0.0.1:25", */ |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
87 | "subdomain@sub.domain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
88 | "local@dash-inDomain.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
89 | "dot.inLocal@foo.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
90 | "a@singleLetterLocal.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
91 | "singleLetterDomain@x.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
92 | "&*=?^+{}'~@validCharsInLocal.net", |
|
31484
b7cfae50e10c
Add two valid email addresses to this list
Mark Doliner <markdoliner@pidgin.im>
parents:
31232
diff
changeset
|
93 | "foor@bar.newTLD", |
|
b7cfae50e10c
Add two valid email addresses to this list
Mark Doliner <markdoliner@pidgin.im>
parents:
31232
diff
changeset
|
94 | "HenryTheGreatWhiteCricket@live.ca", |
|
b7cfae50e10c
Add two valid email addresses to this list
Mark Doliner <markdoliner@pidgin.im>
parents:
31232
diff
changeset
|
95 | "HenryThe__WhiteCricket@hotmail.com" |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
96 | }; |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
97 | |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
98 | const char *invalid_emails[] = { |
|
30442
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
99 | "purple-devel@@lists.sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
100 | "purple@devel@lists.sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
101 | "purple-devel@list..sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
102 | "purple-devel", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
103 | "purple-devel@", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
104 | "@lists.sf.net", |
|
a4f304b33d50
Oh, let's put our original test cases in the two arrays, to make things
Mark Doliner <markdoliner@pidgin.im>
parents:
30440
diff
changeset
|
105 | "totally bogus", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
106 | "missingDomain@.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
107 | "@missingLocal.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
108 | "missingatSign.net", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
109 | "missingDot@com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
110 | "two@@signs.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
111 | "colonButNoPort@127.0.0.1:", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
112 | "" |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
113 | /* "someone-else@127.0.0.1.26", */ |
|
30444
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
114 | ".localStartsWithDot@domain.com", |
|
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
115 | /* "localEndsWithDot.@domain.com", */ /* I don't think this is invalid -- Stu */ |
|
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
116 | /* "two..consecutiveDots@domain.com", */ /* I don't think this is invalid -- Stu */ |
|
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
117 | "domainStartsWithDash@-domain.com", |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
118 | "domainEndsWithDash@domain-.com", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
119 | /* "numbersInTLD@domain.c0m", */ |
|
30444
d871c3fd6637
Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30442
diff
changeset
|
120 | /* "missingTLD@domain.", */ /* This certainly isn't invalid -- Stu */ |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
121 | "! \"#$%(),/;<>[]`|@invalidCharsInLocal.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
122 | "invalidCharsInDomain@! \"#$%(),/;<>_[]`|.org", |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
123 | /* "local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org" */ |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
124 | }; |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
125 | |
| 15104 | 126 | START_TEST(test_util_email_is_valid) |
| 127 | { | |
|
30440
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
128 | size_t i; |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
129 | |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
130 | for (i = 0; i < G_N_ELEMENTS(valid_emails); i++) |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
131 | fail_unless(purple_email_is_valid(valid_emails[i]), "Email address was: %s", valid_emails[i]); |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
132 | |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
133 | for (i = 0; i < G_N_ELEMENTS(invalid_emails); i++) |
|
4ec59d547bff
Expand our test for purple_email_is_valid(). I stumbled across a large list
Mark Doliner <markdoliner@pidgin.im>
parents:
30149
diff
changeset
|
134 | fail_if(purple_email_is_valid(invalid_emails[i]), "Email address was: %s", invalid_emails[i]); |
| 15104 | 135 | } |
| 136 | END_TEST | |
| 137 | ||
|
27727
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
138 | START_TEST(test_util_ipv6_is_valid) |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
139 | { |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
140 | fail_unless(purple_ipv6_address_is_valid("2001:0db8:85a3:0000:0000:8a2e:0370:7334")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
141 | fail_unless(purple_ipv6_address_is_valid("2001:db8:85a3:0:0:8a2e:370:7334")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
142 | fail_unless(purple_ipv6_address_is_valid("2001:db8:85a3::8a2e:370:7334")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
143 | fail_unless(purple_ipv6_address_is_valid("2001:0db8:0:0::1428:57ab")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
144 | fail_unless(purple_ipv6_address_is_valid("::1")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
145 | fail_unless(purple_ipv6_address_is_valid("1::")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
146 | fail_unless(purple_ipv6_address_is_valid("1::1")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
147 | fail_unless(purple_ipv6_address_is_valid("::")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
148 | fail_if(purple_ipv6_address_is_valid("")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
149 | fail_if(purple_ipv6_address_is_valid(":")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
150 | fail_if(purple_ipv6_address_is_valid("1.2.3.4")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
151 | fail_if(purple_ipv6_address_is_valid("2001::FFD3::57ab")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
152 | fail_if(purple_ipv6_address_is_valid("200000000::1")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
153 | fail_if(purple_ipv6_address_is_valid("QWERTY::1")); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
154 | } |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
155 | END_TEST |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
156 | |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
157 | START_TEST(test_util_str_to_time) |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
158 | { |
|
35181
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
159 | struct tm tm; |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
160 | long tz_off; |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
161 | const char *rest; |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
162 | time_t timestamp; |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
163 | |
|
21697
c865512e913f
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20293
diff
changeset
|
164 | fail_unless(377182200 == purple_str_to_time("19811214T12:50:00", TRUE, NULL, NULL, NULL)); |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
165 | fail_unless(1175919261 == purple_str_to_time("20070407T04:14:21", TRUE, NULL, NULL, NULL)); |
|
31232
2a4d30955b3f
Add two new tests to purple_str_to_time(). The second currently fails, but is the format used for our log files\!
Daniel Atallah <datallah@pidgin.im>
parents:
30444
diff
changeset
|
166 | fail_unless(1282941722 == purple_str_to_time("2010-08-27.204202", TRUE, NULL, NULL, NULL)); |
|
35181
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
167 | |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
168 | timestamp = purple_str_to_time("2010-08-27.134202-0700PDT", FALSE, &tm, &tz_off, &rest); |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
169 | fail_unless(1282941722 == timestamp); |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
170 | fail_unless((-7 * 60 * 60) == tz_off); |
|
e5c1b7f9486d
Fix purple_str_to_time() again.
Richard Laager <rlaager@pidgin.im>
parents:
32014
diff
changeset
|
171 | assert_string_equal("PDT", rest); |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
172 | } |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
173 | END_TEST |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
174 | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
175 | START_TEST(test_markup_html_to_xhtml) |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
176 | { |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
177 | gchar *xhtml = NULL; |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
178 | gchar *plaintext = NULL; |
|
33380
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
179 | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
180 | purple_markup_html_to_xhtml("<a>", &xhtml, &plaintext); |
|
27709
4bb974aef0b7
Use assert_string_equal_free() instead of just assert_string_equal()
Mark Doliner <markdoliner@pidgin.im>
parents:
27481
diff
changeset
|
181 | assert_string_equal_free("<a href=\"\"></a>", xhtml); |
|
4bb974aef0b7
Use assert_string_equal_free() instead of just assert_string_equal()
Mark Doliner <markdoliner@pidgin.im>
parents:
27481
diff
changeset
|
182 | assert_string_equal_free("", plaintext); |
|
29227
3e9734bf4422
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <darkrain42@pidgin.im>
parents:
27727
diff
changeset
|
183 | |
|
33380
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
184 | purple_markup_html_to_xhtml("<A href='URL'>ABOUT</a>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
185 | assert_string_equal_free("<a href=\"URL\">ABOUT</a>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
186 | assert_string_equal_free("ABOUT <URL>", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
187 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
188 | purple_markup_html_to_xhtml("<a href='URL'>URL</a>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
189 | assert_string_equal_free("URL", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
190 | assert_string_equal_free("<a href=\"URL\">URL</a>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
191 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
192 | purple_markup_html_to_xhtml("<a href='mailto:mail'>mail</a>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
193 | assert_string_equal_free("mail", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
194 | assert_string_equal_free("<a href=\"mailto:mail\">mail</a>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
195 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
196 | purple_markup_html_to_xhtml("<A href='\"U'R&L'>ABOUT</a>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
197 | assert_string_equal_free("<a href=\""U'R&L\">ABOUT</a>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
198 | assert_string_equal_free("ABOUT <\"U'R&L>", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
199 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
200 | purple_markup_html_to_xhtml("<img src='SRC' alt='ALT'/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
201 | assert_string_equal_free("<img src='SRC' alt='ALT' />", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
202 | assert_string_equal_free("ALT", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
203 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
204 | purple_markup_html_to_xhtml("<img src=\"'S'R&C\" alt=\"'A'L&T\"/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
205 | assert_string_equal_free("<img src=''S'R&C' alt=''A'L&T' />", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
206 | assert_string_equal_free("'A'L&T", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
207 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
208 | purple_markup_html_to_xhtml("<unknown>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
209 | assert_string_equal_free("<unknown>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
210 | assert_string_equal_free("<unknown>", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
211 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
212 | purple_markup_html_to_xhtml("é&", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
213 | assert_string_equal_free("é&", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
214 | assert_string_equal_free("é&", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
215 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
216 | purple_markup_html_to_xhtml("<h1>A<h2>B</h2>C</h1>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
217 | assert_string_equal_free("<h1>A<h2>B</h2>C</h1>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
218 | assert_string_equal_free("ABC", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
219 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
220 | purple_markup_html_to_xhtml("<h1><h2><h3><h4>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
221 | assert_string_equal_free("<h1><h2><h3><h4></h4></h3></h2></h1>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
222 | assert_string_equal_free("", plaintext); |
|
33510
8019461267d9
Merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33380
diff
changeset
|
223 | |
|
33380
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
224 | purple_markup_html_to_xhtml("<italic/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
225 | assert_string_equal_free("<em/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
226 | assert_string_equal_free("", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
227 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
228 | purple_markup_html_to_xhtml("</", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
229 | assert_string_equal_free("</", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
230 | assert_string_equal_free("</", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
231 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
232 | purple_markup_html_to_xhtml("</div>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
233 | assert_string_equal_free("", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
234 | assert_string_equal_free("", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
235 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
236 | purple_markup_html_to_xhtml("<hr/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
237 | assert_string_equal_free("<br/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
238 | assert_string_equal_free("\n", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
239 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
240 | purple_markup_html_to_xhtml("<hr>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
241 | assert_string_equal_free("<br/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
242 | assert_string_equal_free("\n", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
243 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
244 | purple_markup_html_to_xhtml("<br />", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
245 | assert_string_equal_free("<br/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
246 | assert_string_equal_free("\n", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
247 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
248 | purple_markup_html_to_xhtml("<br>INSIDE</br>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
249 | assert_string_equal_free("<br/>INSIDE", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
250 | assert_string_equal_free("\nINSIDE", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
251 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
252 | purple_markup_html_to_xhtml("<div></div>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
253 | assert_string_equal_free("<div></div>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
254 | assert_string_equal_free("", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
255 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
256 | purple_markup_html_to_xhtml("<div/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
257 | assert_string_equal_free("<div/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
258 | assert_string_equal_free("", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
259 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
260 | purple_markup_html_to_xhtml("<div attr='\"&<>'/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
261 | assert_string_equal_free("<div attr='"&<>'/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
262 | assert_string_equal_free("", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
263 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
264 | purple_markup_html_to_xhtml("<div attr=\"'\"/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
265 | assert_string_equal_free("<div attr=\"'\"/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
266 | assert_string_equal_free("", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
267 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
268 | purple_markup_html_to_xhtml("<div/> < <div/>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
269 | assert_string_equal_free("<div/> < <div/>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
270 | assert_string_equal_free(" < ", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
271 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
272 | purple_markup_html_to_xhtml("<div>x</div>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
273 | assert_string_equal_free("<div>x</div>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
274 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
275 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
276 | purple_markup_html_to_xhtml("<b>x</b>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
277 | assert_string_equal_free("<span style='font-weight: bold;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
278 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
279 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
280 | purple_markup_html_to_xhtml("<bold>x</bold>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
281 | assert_string_equal_free("<span style='font-weight: bold;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
282 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
283 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
284 | purple_markup_html_to_xhtml("<strong>x</strong>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
285 | assert_string_equal_free("<span style='font-weight: bold;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
286 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
287 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
288 | purple_markup_html_to_xhtml("<u>x</u>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
289 | assert_string_equal_free("<span style='text-decoration: underline;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
290 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
291 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
292 | purple_markup_html_to_xhtml("<underline>x</underline>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
293 | assert_string_equal_free("<span style='text-decoration: underline;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
294 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
295 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
296 | purple_markup_html_to_xhtml("<s>x</s>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
297 | assert_string_equal_free("<span style='text-decoration: line-through;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
298 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
299 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
300 | purple_markup_html_to_xhtml("<strike>x</strike>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
301 | assert_string_equal_free("<span style='text-decoration: line-through;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
302 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
303 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
304 | purple_markup_html_to_xhtml("<sub>x</sub>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
305 | assert_string_equal_free("<span style='vertical-align:sub;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
306 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
307 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
308 | purple_markup_html_to_xhtml("<sup>x</sup>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
309 | assert_string_equal_free("<span style='vertical-align:super;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
310 | assert_string_equal_free("x", plaintext); |
|
29227
3e9734bf4422
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <darkrain42@pidgin.im>
parents:
27727
diff
changeset
|
311 | |
|
3e9734bf4422
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <darkrain42@pidgin.im>
parents:
27727
diff
changeset
|
312 | purple_markup_html_to_xhtml("<FONT>x</FONT>", &xhtml, &plaintext); |
|
3e9734bf4422
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <darkrain42@pidgin.im>
parents:
27727
diff
changeset
|
313 | assert_string_equal_free("x", xhtml); |
|
3e9734bf4422
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <darkrain42@pidgin.im>
parents:
27727
diff
changeset
|
314 | assert_string_equal_free("x", plaintext); |
|
33380
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
315 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
316 | purple_markup_html_to_xhtml("<font face=\"'Times>New & Roman'\">x</font>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
317 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
318 | assert_string_equal_free("<span style='font-family: \"Times>New & Roman\";'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
319 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
320 | purple_markup_html_to_xhtml("<font back=\"'color>blue&red'\">x</font>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
321 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
322 | assert_string_equal_free("<span style='background: \"color>blue&red\";'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
323 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
324 | purple_markup_html_to_xhtml("<font color=\"'color>blue&red'\">x</font>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
325 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
326 | assert_string_equal_free("<span style='color: \"color>blue&red\";'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
327 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
328 | purple_markup_html_to_xhtml("<font size=1>x</font>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
329 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
330 | assert_string_equal_free("<span style='font-size: xx-small;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
331 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
332 | purple_markup_html_to_xhtml("<font size=432>x</font>", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
333 | assert_string_equal_free("x", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
334 | assert_string_equal_free("<span style='font-size: medium;'>x</span>", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
335 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
336 | /* The following tests document a behaviour that looks suspicious */ |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
337 | |
| 35161 | 338 | /* bug report https://developer.pidgin.im/ticket/13485 */ |
|
33380
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
339 | purple_markup_html_to_xhtml("<!--COMMENT-->", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
340 | assert_string_equal_free("<!--COMMENT-->", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
341 | assert_string_equal_free("COMMENT-->", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
342 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
343 | /* no bug report */ |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
344 | purple_markup_html_to_xhtml("<br />", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
345 | assert_string_equal_free("<br />", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
346 | assert_string_equal_free("<br />", plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
347 | |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
348 | /* same code section as <br /> */ |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
349 | purple_markup_html_to_xhtml("<hr />", &xhtml, &plaintext); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
350 | assert_string_equal_free("<hr />", xhtml); |
|
c600a505402d
patch from loic to fix some bad html -> xhtml conversion
Nathan Walp <nwalp@pidgin.im>
parents:
32014
diff
changeset
|
351 | assert_string_equal_free("<hr />", plaintext); |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
352 | } |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
353 | END_TEST |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
354 | |
|
30143
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
355 | START_TEST(test_utf8_strip_unprintables) |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
356 | { |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
357 | fail_unless(NULL == purple_utf8_strip_unprintables(NULL)); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
358 | /* invalid UTF-8 */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
359 | #if 0 |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
360 | /* disabled because make check fails on an assertion */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
361 | fail_unless(NULL == purple_utf8_strip_unprintables("abc\x80\x7f")); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
362 | #endif |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
363 | /* \t, \n, \r, space */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
364 | assert_string_equal_free("ab \tcd\nef\r ", purple_utf8_strip_unprintables("ab \tcd\nef\r ")); |
|
30149
b552354d087a
util tests: Add a test for all the lower-ASCII control characters excluding the
Paul Aurich <darkrain42@pidgin.im>
parents:
30143
diff
changeset
|
365 | /* ASCII control characters (stripped) */ |
|
b552354d087a
util tests: Add a test for all the lower-ASCII control characters excluding the
Paul Aurich <darkrain42@pidgin.im>
parents:
30143
diff
changeset
|
366 | assert_string_equal_free(" aaaa ", purple_utf8_strip_unprintables( |
|
b552354d087a
util tests: Add a test for all the lower-ASCII control characters excluding the
Paul Aurich <darkrain42@pidgin.im>
parents:
30143
diff
changeset
|
367 | "\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10 aaaa " |
|
b552354d087a
util tests: Add a test for all the lower-ASCII control characters excluding the
Paul Aurich <darkrain42@pidgin.im>
parents:
30143
diff
changeset
|
368 | "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F")); |
|
30143
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
369 | /* Basic ASCII */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
370 | assert_string_equal_free("Foobar", purple_utf8_strip_unprintables("Foobar")); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
371 | /* 0xE000 - 0xFFFD (UTF-8 encoded) */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
372 | /* U+F1F7 */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
373 | assert_string_equal_free("aaaa\xef\x87\xb7", purple_utf8_strip_unprintables("aaaa\xef\x87\xb7")); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
374 | #if 0 |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
375 | /* disabled because make check fails on an assertion */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
376 | /* U+DB80 (Private Use High Surrogate, First) -- should be stripped */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
377 | assert_string_equal_free("aaaa", purple_utf8_strip_unprintables("aaaa\xed\xa0\x80")); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
378 | /* U+FFFE (should be stripped) */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
379 | assert_string_equal_free("aaaa", purple_utf8_strip_unprintables("aaaa\xef\xbf\xbe")); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
380 | #endif |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
381 | /* U+FEFF (should not be stripped) */ |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
382 | assert_string_equal_free("aaaa\xef\xbb\xbf", purple_utf8_strip_unprintables("aaaa\xef\xbb\xbf")); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
383 | } |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
384 | END_TEST |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
385 | |
|
27481
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
386 | START_TEST(test_mime_decode_field) |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
387 | { |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
388 | gchar *result = purple_mime_decode_field("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?="); |
|
27709
4bb974aef0b7
Use assert_string_equal_free() instead of just assert_string_equal()
Mark Doliner <markdoliner@pidgin.im>
parents:
27481
diff
changeset
|
389 | assert_string_equal_free("Keld Jørn Simonsen", result); |
|
27481
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
390 | } |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
391 | END_TEST |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
392 | |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
393 | START_TEST(test_strdup_withhtml) |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
394 | { |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
395 | gchar *result = purple_strdup_withhtml("hi\r\nthere\n"); |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
396 | assert_string_equal_free("hi<BR>there<BR>", result); |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
397 | } |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
398 | END_TEST |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
399 | |
| 15104 | 400 | Suite * |
| 401 | util_suite(void) | |
| 402 | { | |
| 403 | Suite *s = suite_create("Utility Functions"); | |
| 404 | ||
| 405 | TCase *tc = tcase_create("Base16"); | |
| 406 | tcase_add_test(tc, test_util_base16_encode); | |
| 407 | tcase_add_test(tc, test_util_base16_decode); | |
| 408 | suite_add_tcase(s, tc); | |
| 409 | ||
| 410 | tc = tcase_create("Base64"); | |
| 411 | tcase_add_test(tc, test_util_base64_encode); | |
| 412 | tcase_add_test(tc, test_util_base64_decode); | |
| 413 | suite_add_tcase(s, tc); | |
| 414 | ||
| 415 | tc = tcase_create("Filenames"); | |
| 416 | tcase_add_test(tc, test_util_escape_filename); | |
| 417 | tcase_add_test(tc, test_util_unescape_filename); | |
| 418 | suite_add_tcase(s, tc); | |
| 419 | ||
| 420 | tc = tcase_create("Strip Mnemonic"); | |
| 421 | tcase_add_test(tc, test_util_text_strip_mnemonic); | |
| 422 | suite_add_tcase(s, tc); | |
| 423 | ||
| 424 | tc = tcase_create("Email"); | |
| 425 | tcase_add_test(tc, test_util_email_is_valid); | |
| 426 | suite_add_tcase(s, tc); | |
| 427 | ||
|
27727
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
428 | tc = tcase_create("IPv6"); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
429 | tcase_add_test(tc, test_util_ipv6_is_valid); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
430 | suite_add_tcase(s, tc); |
|
0c888674bbfc
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <darkrain42@pidgin.im>
parents:
27709
diff
changeset
|
431 | |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
432 | tc = tcase_create("Time"); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
433 | tcase_add_test(tc, test_util_str_to_time); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
434 | suite_add_tcase(s, tc); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
435 | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
436 | tc = tcase_create("Markup"); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
437 | tcase_add_test(tc, test_markup_html_to_xhtml); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
438 | suite_add_tcase(s, tc); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
439 | |
|
30143
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
440 | tc = tcase_create("Stripping Unparseables"); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
441 | tcase_add_test(tc, test_utf8_strip_unprintables); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
442 | suite_add_tcase(s, tc); |
|
468e3b69fd10
util: Better validation of the allowed character values in XML 1.0
Paul Aurich <darkrain42@pidgin.im>
parents:
29227
diff
changeset
|
443 | |
|
27481
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
444 | tc = tcase_create("MIME"); |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
445 | tcase_add_test(tc, test_mime_decode_field); |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
446 | suite_add_tcase(s, tc); |
|
472fc883fe3c
* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL)
Mark Doliner <markdoliner@pidgin.im>
parents:
26553
diff
changeset
|
447 | |
|
32014
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
448 | tc = tcase_create("strdup_withhtml"); |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
449 | tcase_add_test(tc, test_strdup_withhtml); |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
450 | suite_add_tcase(s, tc); |
|
daedb1559529
A unit test check from the EFF
Mark Doliner <markdoliner@pidgin.im>
parents:
31484
diff
changeset
|
451 | |
| 15104 | 452 | return s; |
| 453 | } |