| 1 |
import unittest |
|---|
| 2 |
import cleanhtml |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
trial = """ |
|---|
| 6 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
|---|
| 7 |
"http://www.w3.org/TR/xhtml1/DTD/strict.dtd"> |
|---|
| 8 |
<html xmlns="http://www.w3.org/TR/xhtml1/strict" xml:lang="en" lang="en"> |
|---|
| 9 |
|
|---|
| 10 |
<head> |
|---|
| 11 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|---|
| 12 |
<title>junct Account</title> |
|---|
| 13 |
<link href='/junct/junct.css' rel='stylesheet' type='text/css' /> |
|---|
| 14 |
<link href='account.css' rel='stylesheet' type='text/css' /> |
|---|
| 15 |
<script type='text/javascript'> |
|---|
| 16 |
<!-- |
|---|
| 17 |
|
|---|
| 18 |
function popup(page, height, args) { |
|---|
| 19 |
winargs = 'height=' + height + ',width=400,resizable=yes,scrollbars=no'; |
|---|
| 20 |
if (args) { |
|---|
| 21 |
if (args != "") args = "?" + args; |
|---|
| 22 |
} else { |
|---|
| 23 |
args = "?ID="; |
|---|
| 24 |
} |
|---|
| 25 |
window.open("/junct/" + page + ".htm" + args, "_blank", winargs); |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
//--> |
|---|
| 29 |
</script> |
|---|
| 30 |
</head> |
|---|
| 31 |
|
|---|
| 32 |
<body> |
|---|
| 33 |
|
|---|
| 34 |
<script type='text/javascript'>self.name = 'page2004-02-29T00:04:04.327000_7ffffff5';</script> |
|---|
| 35 |
<div class='freecommands'> |
|---|
| 36 |
<a href="/junct/edit.htm" title="Create a New junct Topic">New</a> |
|---|
| 37 |
<a href="/junct/recent.htm" title="Show Topics which have been recently created or changed">Recent</a> |
|---|
| 38 |
<a href="/junct/upload.htm" title="Upload a file as a new junct Topic">Upload</a> |
|---|
| 39 |
<a href="javascript:void(popup('search', '300'))" title="Search Topics">Search</a> |
|---|
| 40 |
<a href="/junct/calendar.htm" title="Show My Calendar (current week)">Calendar</a> |
|---|
| 41 |
<a href="/junct/progress.htm" title="Show My Progress">Progress</a> |
|---|
| 42 |
<a title="Administer Junct" href="/junct/admin.htm">Admin</a> |
|---|
| 43 |
<a href="/junct/groups.htm" title="Manage My Groups">Groups</a> |
|---|
| 44 |
<a href="/junct/account.htm" title="Manage My Account">Me</a> |
|---|
| 45 |
<a href="/junct/" title="Visit your Home Topic">Home</a> |
|---|
| 46 |
</div> |
|---|
| 47 |
|
|---|
| 48 |
<h1 class='title'>My Account</h1> |
|---|
| 49 |
|
|---|
| 50 |
<div class='maincontent' id='accountsettings'> |
|---|
| 51 |
<form name='accountform' action='/junct/accountsubmit.htm' method='post' target='acctsubwin' onSubmit='window.open("", this.target, "height=150,width=400,resizable=yes,scrollbars=no")'> |
|---|
| 52 |
<table> |
|---|
| 53 |
<tr> |
|---|
| 54 |
<th>Home Topic</th> |
|---|
| 55 |
<td><input name='Home Topic' value="Starting Points" size='50' /></td> |
|---|
| 56 |
</tr> |
|---|
| 57 |
<tr> |
|---|
| 58 |
<th>Size of the editing window</th> |
|---|
| 59 |
<td>Rows: <input name='EditRows' value="25" size='3' /> |
|---|
| 60 |
Columns: <input name='EditCols' value="90" size='3' /></td> |
|---|
| 61 |
</tr> |
|---|
| 62 |
<tr> |
|---|
| 63 |
<th>Number of days to show in Recent Topics</th> |
|---|
| 64 |
<td><input name='Recent Length' value="3" size='4' /></td> |
|---|
| 65 |
</tr> |
|---|
| 66 |
<tr> |
|---|
| 67 |
<th>Allow Invitations from groups</th> |
|---|
| 68 |
<td><input type='checkbox' name='AllowInvitations' checked="checked" /></td> |
|---|
| 69 |
</tr> |
|---|
| 70 |
<tr> |
|---|
| 71 |
<th>My email addresses</th> |
|---|
| 72 |
<td> |
|---|
| 73 |
<a href='javascript:void(popup("emailadd", "250"))' title='Add an email address to your account'>Add an address</a><br /> |
|---|
| 74 |
Notify<br /> |
|---|
| 75 |
<div class='Address'> |
|---|
| 76 |
<input type='checkbox' name='__Notify_1' checked="checked"/> |
|---|
| 77 |
fumanchu@aminus.org |
|---|
| 78 |
<a href='javascript:void(popup("emaildrop", "250", "ID=1"))'>Drop</a> |
|---|
| 79 |
</div> |
|---|
| 80 |
</td> |
|---|
| 81 |
</tr> |
|---|
| 82 |
</table> |
|---|
| 83 |
<input type='submit' class='formsubmit' value='Submit' /> |
|---|
| 84 |
</form> |
|---|
| 85 |
</div> |
|---|
| 86 |
|
|---|
| 87 |
</body> |
|---|
| 88 |
</html> |
|---|
| 89 |
""" |
|---|
| 90 |
|
|---|
| 91 |
class CleanTests(unittest.TestCase): |
|---|
| 92 |
|
|---|
| 93 |
def test_Plaintext(self): |
|---|
| 94 |
trial = """<body>Puerto Peñasco</body>""" |
|---|
| 95 |
final = u"""Puerto Pe\xf1asco""" |
|---|
| 96 |
self.assertEqual(cleanhtml.plaintext(trial), final) |
|---|
| 97 |
|
|---|
| 98 |
def test_StripTags(self): |
|---|
| 99 |
final = """ |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
junct Account |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
self.name = 'page2004-02-29T00:04:04.327000_7ffffff5'; |
|---|
| 116 |
|
|---|
| 117 |
New |
|---|
| 118 |
Recent |
|---|
| 119 |
Upload |
|---|
| 120 |
Search |
|---|
| 121 |
Calendar |
|---|
| 122 |
Progress |
|---|
| 123 |
Admin |
|---|
| 124 |
Groups |
|---|
| 125 |
Me |
|---|
| 126 |
Home |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
My Account |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
Home Topic |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
Size of the editing window |
|---|
| 140 |
Rows: |
|---|
| 141 |
Columns: |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
Number of days to show in Recent Topics |
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
Allow Invitations from groups |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
My email addresses |
|---|
| 153 |
|
|---|
| 154 |
Add an address |
|---|
| 155 |
Notify |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
fumanchu@aminus.org |
|---|
| 159 |
Drop |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
""" |
|---|
| 171 |
self.assertEqual(cleanhtml.striptags(trial), final) |
|---|
| 172 |
|
|---|
| 173 |
def test_Sanitize(self): |
|---|
| 174 |
|
|---|
| 175 |
final = """ |
|---|
| 176 |
<!-- Prohibited Content --> |
|---|
| 177 |
<!-- Prohibited Content --> |
|---|
| 178 |
|
|---|
| 179 |
<!-- Prohibited Content --> |
|---|
| 180 |
<!-- Prohibited Content --> |
|---|
| 181 |
<!-- Prohibited Content -->junct Account<!-- Prohibited Content --> |
|---|
| 182 |
<!-- Prohibited Content --> |
|---|
| 183 |
<!-- Prohibited Content --> |
|---|
| 184 |
<!-- Prohibited Content --> |
|---|
| 185 |
|
|---|
| 186 |
<!-- Prohibited Content --> |
|---|
| 187 |
<!-- Prohibited Content --> |
|---|
| 188 |
|
|---|
| 189 |
<!-- Prohibited Content --> |
|---|
| 190 |
|
|---|
| 191 |
<!-- Prohibited Content -->self.name = 'page2004-02-29T00:04:04.327000_7ffffff5';<!-- Prohibited Content --> |
|---|
| 192 |
<div class="freecommands"> |
|---|
| 193 |
<a href="/junct/edit.htm" title="Create a New junct Topic">New</a> |
|---|
| 194 |
<a href="/junct/recent.htm" title="Show Topics which have been recently created or changed">Recent</a> |
|---|
| 195 |
<a href="/junct/upload.htm" title="Upload a file as a new junct Topic">Upload</a> |
|---|
| 196 |
<a href="javascript:void(popup('search', '300'))" title="Search Topics">Search</a> |
|---|
| 197 |
<a href="/junct/calendar.htm" title="Show My Calendar (current week)">Calendar</a> |
|---|
| 198 |
<a href="/junct/progress.htm" title="Show My Progress">Progress</a> |
|---|
| 199 |
<a title="Administer Junct" href="/junct/admin.htm">Admin</a> |
|---|
| 200 |
<a href="/junct/groups.htm" title="Manage My Groups">Groups</a> |
|---|
| 201 |
<a href="/junct/account.htm" title="Manage My Account">Me</a> |
|---|
| 202 |
<a href="/junct/" title="Visit your Home Topic">Home</a> |
|---|
| 203 |
</div> |
|---|
| 204 |
|
|---|
| 205 |
<h1 class="title">My Account</h1> |
|---|
| 206 |
|
|---|
| 207 |
<div class="maincontent" id="accountsettings"> |
|---|
| 208 |
<!-- Prohibited Content --> |
|---|
| 209 |
<table> |
|---|
| 210 |
<tr> |
|---|
| 211 |
<th>Home Topic</th> |
|---|
| 212 |
<td><!-- Prohibited Content --></td> |
|---|
| 213 |
</tr> |
|---|
| 214 |
<tr> |
|---|
| 215 |
<th>Size of the editing window</th> |
|---|
| 216 |
<td>Rows: <!-- Prohibited Content --> |
|---|
| 217 |
Columns: <!-- Prohibited Content --></td> |
|---|
| 218 |
</tr> |
|---|
| 219 |
<tr> |
|---|
| 220 |
<th>Number of days to show in Recent Topics</th> |
|---|
| 221 |
<td><!-- Prohibited Content --></td> |
|---|
| 222 |
</tr> |
|---|
| 223 |
<tr> |
|---|
| 224 |
<th>Allow Invitations from groups</th> |
|---|
| 225 |
<td><!-- Prohibited Content --></td> |
|---|
| 226 |
</tr> |
|---|
| 227 |
<tr> |
|---|
| 228 |
<th>My email addresses</th> |
|---|
| 229 |
<td> |
|---|
| 230 |
<a href='javascript:void(popup("emailadd", "250"))' title="Add an email address to your account">Add an address</a><br /> |
|---|
| 231 |
Notify<br /> |
|---|
| 232 |
<div class="Address"> |
|---|
| 233 |
<!-- Prohibited Content --> |
|---|
| 234 |
fumanchu@aminus.org |
|---|
| 235 |
<a href='javascript:void(popup("emaildrop", "250", "ID=1"))'>Drop</a> |
|---|
| 236 |
</div> |
|---|
| 237 |
</td> |
|---|
| 238 |
</tr> |
|---|
| 239 |
</table> |
|---|
| 240 |
<!-- Prohibited Content --> |
|---|
| 241 |
<!-- Prohibited Content --> |
|---|
| 242 |
</div> |
|---|
| 243 |
|
|---|
| 244 |
<!-- Prohibited Content --> |
|---|
| 245 |
<!-- Prohibited Content --> |
|---|
| 246 |
""" |
|---|
| 247 |
self.assertEqual(cleanhtml.sanitize(trial), final) |
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
if __name__ == "__main__": |
|---|
| 251 |
unittest.main() |
|---|