<?php
-// $Id: SpamPickupTest.php,v 1.3 2007/08/20 14:37:23 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 = 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']);
}
}