<?php
-// $Id: SpamPickupTest.php,v 1.2 2007/07/02 15:27:20 henoheno Exp $
+// $Id: SpamPickupTest.php,v 1.5 2008/12/27 11:50:55 henoheno Exp $
// Copyright (C) 2007 heno
//
// Design test case for spam.php (called from runner.php)
function testFunc_host_normalize()
{
- // Null
+ // Invalid: Null
foreach($this->setup_string_null() as $key => $value){
$this->assertEquals('', host_normalize($value), $key);
}
// Hostname is case-insensitive
$this->assertEquals('example.org', host_normalize('ExAMPle.ORG'));
- // Cut 'www' (destructive)
+ // Cut 'www' with traditional ASCII-based FQDN (destructive)
$this->assertEquals('example.org', host_normalize('WWW.example.org'));
+
+ // Don't cut 'www' with Non-ASCII-based string such as IDN
+ $this->assertEquals("www.example.org\0foobar",
+ host_normalize("WWW.example.org\0foobar"));
}
function testFunc_port_normalize()
$results = uri_pickup_normalize(uri_pickup($test_string));
$this->assertEquals('backslash.org', $results[0]['host']);
+ // Divider: percent-encoded
+ //$test_string = ' http%3A%2F%5Cpercent-encoded.org%5Cfobar.html ';
+ //$results = uri_pickup_normalize(uri_pickup($test_string));
+ //$this->assertEquals('percent-encoded.org', $results[0]['host']);
+
// Host: Underscore
$test_string = ' http://under_score.org/fobar.html ';
$results = uri_pickup_normalize(uri_pickup($test_string));
$this->assertEquals('foo.html', $results[0]['file']);
}
+ function testFunc_spam_uri_pickup()
+ {
+ // Divider: percent-encoded
+ $test_string = ' http://victim.example.org/http%3A%2F%5Cnasty.example.org ';
+ $results = spam_uri_pickup($test_string);
+ $this->assertEquals('victim.example.org', $results[0]['host']);
+ $this->assertEquals('nasty.example.org', $results[1]['host']);
+
+ // Domain exposure (site:)
+ $test_string = ' http://search.example.org/?q=%20site:nasty.example.org ';
+ $results = spam_uri_pickup($test_string);
+ $this->assertEquals('nasty.example.org', $results[0]['host']);
+ $this->assertEquals('search.example.org', $results[1]['host']);
+
+ // Domain exposure (%20site:)
+ $test_string = ' http://search2.example.org/?q=%20site:nasty2.example.org ';
+ $results = spam_uri_pickup($test_string);
+ $this->assertEquals('nasty2.example.org', $results[0]['host']);
+ $this->assertEquals('search2.example.org', $results[1]['host']);
+ }
}
?>
\ No newline at end of file