#include #include #include #include #include #include #include #include #include #include #include #include int test_url(char *url, char *expected_result){ char buf[SMALLBUFSIZE]; snprintf(buf, sizeof(buf)-1, "%s", url); fixURL(buf); if(strcmp(buf, expected_result)){ printf("FAILED: '%s' => fixed: '%s', expected: '%s'\n", url, buf, expected_result); return 1; } return 0; } int test_translate(char *what, char *expected, struct _state *state){ char buf[SMALLBUFSIZE]; snprintf(buf, sizeof(buf)-1, "%s", what); translateLine((unsigned char*)buf, state); if(strcmp(buf, expected)){ printf("FAILED: '%s' => fixed: '%s', expected: '%s'\n", what, buf, expected); return 1; } return 0; } int test_urls(){ int count=0; count += test_url("http://sourceforge.net/projects/blogsmanager/", "__URL__sourceforgeXnet "); count += test_url("http://localhost/blogs/_authors_list.php?a=search&value=1&SearchFor=muuratsalo&SearchOption=Contains&SearchField=[SQL", "__URL__localhost "); count += test_url("http://www.debian.org/security/faq", "__URL__wwwXdebianXorg "); count += test_url("http://www.debian.org/", "__URL__wwwXdebianXorg "); count += test_url("https://www.debian.org", "__URL__wwwXdebianXorg "); count += test_url("HTTP://www.debian.o", "__URL__wwwXdebianXo "); count += test_url("http://www.debian.", "__URL__wwwXdebian "); count += test_url("www.debian.org", "__URL__wwwXdebianXorg "); count += test_url("http://web.nvd.nist.gov/view/vuln/detail?vulnId=3DCVE-2011-3892", "__URL__webXnvdXnistXgov "); count += test_url("http://bugs.sitracker.org/view.php?id=1737", "__URL__bugsXsitrackerXorg "); count += test_url("http://googlechromereleases.blogspot.com/2011/11/stable-channel-update.ht", "__URL__googlechromereleasesXblogspotXcom "); count += test_url("http://security.gentoo.org/glsa/glsa-201111-05.xml", "__URL__securityXgentooXorg "); count += test_url("https://bugs.gentoo.org.", "__URL__bugsXgentooXorg "); count += test_url("https://bugs.gentoo.org./ajajajajaaj", "__URL__bugsXgentooXorg "); count += test_url("http://creativecommons.org/licenses/by-sa/2.5", "__URL__creativecommonsXorg "); count += test_url("http://www.site.com/[path]/wp-content/plugins/advanced-text-widget/advancedtext.php?page=[xss]", "__URL__wwwXsiteXcom "); count += test_url("http://canadamedshealth.ru", "__URL__canadamedshealthXru "); count += test_url("http://[HOSTNAME]:4848/configuration/httpListenerEdit.jsf?name=&configName=server-config", "__URL__[HOSTNAME]:4848 "); count += test_url("http://go.theregister.com/news/http://www.theregister.co.uk/2007/07/", "__URL__goXtheregisterXcom "); count += test_url("http://dl.shadowserver.org/IpE6yFKxIPARB8447vAQoyeVtbs?Rq123jTRTTrzApVs0vTzyQ", "__URL__dlXshadowserverXorg "); count += test_url("http://dl.shadowserver.org/IpE6yFKx%EAPARB8447vAQoyeVtbs?Rq123jTRTTrzApVs0vTzyQ", "__URL__dlXshadowserverXorg "); count += test_url("", ""); return count; } int test_translates(){ int count=0; struct _state state; init_state(&state); count += test_translate("To: \"Suto, Janos\" ", "To Suto Janos Janos.Suto@foo.bar", &state); count += test_translate("Ez most akkor beteg, vagy sem?", "Ez most akkor beteg vagy sem ", &state); count += test_translate("MAIL FROM: ", "MAIL FROM zoltan.szabo@zte.com.cn ", &state); count += test_translate("Enjoy your game, and then enjoy your jackpot!", "Enjoy your game and then enjoy your jackpot!", &state); count += test_translate("Az Ãn által megküldött,", "Az Ãn által megküldött ", &state); return count; } int test_html(char *what, char *expected, struct _state *state){ char buf[SMALLBUFSIZE]; snprintf(buf, sizeof(buf)-1, "%s", what); markHTML(buf, state); if(strcmp(buf, expected)){ printf("FAILED: '%s' => fixed: '%s', expected: '%s'\n", what, buf, expected); return 1; } //printf("OK: '%s' => fixed: '%s', expected: '%s'\n", what, buf, expected); return 0; } int test_htmls(){ int count=0; struct _state state; init_state(&state); count += test_html("", " ", &state); count += test_html("jackpot!

", "jackpot! ", &state); count += test_html("

Enjoy your game, and then enjoy your =", " Enjoy your game, and then enjoy your =", &state); count += test_html("

ooooo", " ooooo", &state); count += test_html(" ", " ", &state); count += test_html("

", " ", &state); count += test_html("
", " ", &state); count += test_html("Viagra50/100mg - $1.85 |BUY NOW|
", " Viagra50/100mg - $1.85 |BUY NOW| ", &state); count += test_html("High Qua1ityMedications + Discount On All Reorders +
", "High Qua1ityMedications + Discount On All Reorders + ", &state); count += test_html("Free Shipping Options + Free Pills With Every Order = Best Deal Ever!
''''''''''click here''''''''''

", " Free Shipping Options + Free Pills With Every Order = Best Deal Ever! ''''''''''click here'''''''''", &state); count += test_html("http://bbb.fu/2.gif", "http://bbb.fu/2.gif", &state); count += test_html("", " ", &state); count += test_html("