summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/Common_test.php17
-rw-r--r--tests/codeigniter/core/Config_test.php58
-rw-r--r--tests/codeigniter/core/Input_test.php46
-rw-r--r--tests/codeigniter/core/Lang_test.php22
-rw-r--r--tests/codeigniter/core/Loader_test.php39
-rw-r--r--tests/codeigniter/core/Log_test.php63
-rw-r--r--tests/codeigniter/core/Security_test.php142
-rw-r--r--tests/codeigniter/core/URI_test.php9
-rw-r--r--tests/codeigniter/core/Utf8_test.php53
-rw-r--r--tests/codeigniter/core/compat/password_test.php5
-rw-r--r--tests/codeigniter/core/compat/standard_test.php234
11 files changed, 333 insertions, 355 deletions
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
index 999b49cb3..ca19e5de0 100644
--- a/tests/codeigniter/core/Common_test.php
+++ b/tests/codeigniter/core/Common_test.php
@@ -47,6 +47,23 @@ class Common_test extends CI_TestCase {
html_escape('Here is a string containing "quoted" text.'),
'Here is a string containing "quoted" text.'
);
+
+ $this->assertEquals(
+ html_escape(array('associative' => 'and', array('multi' => 'dimentional'))),
+ array('associative' => 'and', array('multi' => 'dimentional'))
+ );
}
+ // ------------------------------------------------------------------------
+
+ public function test_remove_invisible_characters()
+ {
+ $raw_string = 'Here is a string containing invisible'.chr(0x08).' text %0e.';
+ $removed_string = 'Here is a string containing invisible text %0e.';
+ $this->assertEquals($removed_string, remove_invisible_characters($raw_string, FALSE));
+
+ $raw_string = 'Here is a string %0econtaining url_encoded invisible%1F text.';
+ $removed_string = 'Here is a string containing url_encoded invisible text.';
+ $this->assertEquals($removed_string, remove_invisible_characters($raw_string));
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index f125fc6e9..5201d46dc 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -79,46 +79,33 @@ class Config_test extends CI_TestCase {
$old_script_name = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL;
$old_script_filename = $_SERVER['SCRIPT_FILENAME'];
$old_https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : NULL;
+ $old_server_addr = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : NULL;
- // Setup server vars for detection
- $host = 'test.com';
- $path = '/';
- $script = 'base_test.php';
- $_SERVER['HTTP_HOST'] = $host;
- $_SERVER['SCRIPT_NAME'] = $path.$script;
- $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/'.$script;
-
- // Rerun constructor
+ // The 'Host' header is user input and must not be trusted
+ $_SERVER['HTTP_HOST'] = 'test.com';
$this->config = new $cls;
+ $this->assertEquals('http://localhost/', $this->config->base_url());
- // Test plain detected (root)
- $this->assertEquals('http://'.$host.$path, $this->config->base_url());
-
- // Rerun constructor
- $path = '/path/';
- $_SERVER['SCRIPT_NAME'] = $path.$script;
- $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/'.$path.$script;
+ // However, we may fallback to the server's IP address
+ $_SERVER['SERVER_ADDR'] = '127.0.0.1';
+ $_SERVER['SCRIPT_NAME'] = '/base_test.php';
+ $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/base_test.php';
$this->config = new $cls;
+ $this->assertEquals('http://127.0.0.1/', $this->config->base_url());
- // Test plain detected (subfolder)
- $this->assertEquals('http://'.$host.$path, $this->config->base_url());
-
- // Rerun constructor
+ // Making sure that HTTPS and URI path are also detected
$_SERVER['HTTPS'] = 'on';
+ $_SERVER['SCRIPT_NAME'] = '/path/base_test.php';
+ $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/path/base_test.php';
$this->config = new $cls;
-
- // Test secure detected
- $this->assertEquals('https://'.$host.$path, $this->config->base_url());
+ $this->assertEquals('https://127.0.0.1/path/', $this->config->base_url());
// Restore server vars
- if ($old_host === NULL) unset($_SERVER['HTTP_HOST']);
- else $_SERVER['HTTP_HOST'] = $old_host;
- if ($old_script_name === NULL) unset($_SERVER['SCRIPT_NAME']);
- else $_SERVER['SCRIPT_NAME'] = $old_script_name;
- if ($old_https === NULL) unset($_SERVER['HTTPS']);
- else $_SERVER['HTTPS'] = $old_https;
-
+ $_SERVER['HTTP_HOST'] = $old_host;
+ $_SERVER['SCRIPT_NAME'] = $old_script_name;
$_SERVER['SCRIPT_FILENAME'] = $old_script_filename;
+ $_SERVER['HTTPS'] = $old_https;
+ $_SERVER['SERVER_ADDR'] = $old_server_addr;
}
// --------------------------------------------------------------------
@@ -140,6 +127,8 @@ class Config_test extends CI_TestCase {
$this->assertEquals($index_page.'/'.$uri, $this->config->site_url($uri));
$this->assertEquals($index_page.'/'.$uri.'/'.$uri2, $this->config->site_url(array($uri, $uri2)));
+ $this->assertEquals($index_page.'/test/', $this->config->site_url('test/'));
+
$suffix = 'ing';
$this->config->set_item('url_suffix', $suffix);
@@ -163,13 +152,6 @@ class Config_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_system_url()
- {
- $this->assertEquals($this->cfg['base_url'].'system/', $this->config->system_url());
- }
-
- // --------------------------------------------------------------------
-
public function test_load()
{
// Test regular load
@@ -248,4 +230,4 @@ class Config_test extends CI_TestCase {
$this->assertNull($this->config->load($file));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index c56900d22..e068a84be 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -12,12 +12,8 @@ class Input_test extends CI_TestCase {
$this->ci_set_config('global_xss_filtering', FALSE);
$this->ci_set_config('csrf_protection', FALSE);
- $security = new Mock_Core_Security();
-
- $this->ci_set_config('charset', 'UTF-8');
- $utf8 = new Mock_Core_Utf8();
-
- $this->input = new Mock_Core_Input($security, $utf8);
+ $security = new Mock_Core_Security('UTF-8');
+ $this->input = new CI_Input($security);
}
// --------------------------------------------------------------------
@@ -122,14 +118,17 @@ class Input_test extends CI_TestCase {
public function test_fetch_from_array()
{
+ $reflection = new ReflectionMethod($this->input, '_fetch_from_array');
+ $reflection->setAccessible(TRUE);
+
$data = array(
'foo' => 'bar',
'harm' => 'Hello, i try to <script>alert(\'Hack\');</script> your site',
);
- $foo = $this->input->fetch_from_array($data, 'foo');
- $harm = $this->input->fetch_from_array($data, 'harm');
- $harmless = $this->input->fetch_from_array($data, 'harm', TRUE);
+ $foo = $reflection->invokeArgs($this->input, [&$data, 'foo']);
+ $harm = $reflection->invokeArgs($this->input, [&$data, 'harm']);
+ $harmless = $reflection->invokeArgs($this->input, [&$data, 'harm', TRUE]);
$this->assertEquals('bar', $foo);
$this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $harm);
@@ -217,51 +216,60 @@ class Input_test extends CI_TestCase {
public function test_ip_address()
{
- $this->input->ip_address = '127.0.0.1';
+ $reflection = new ReflectionProperty($this->input, 'ip_address');
+ $reflection->setAccessible(TRUE);
+
+ $reflection->setValue($this->input, '127.0.0.1');
$this->assertEquals('127.0.0.1', $this->input->ip_address());
// 127.0.0.1 is set in our Bootstrap file
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->assertEquals('127.0.0.1', $this->input->ip_address());
// Invalid
$_SERVER['REMOTE_ADDR'] = 'invalid_ip_address';
- $this->input->ip_address = FALSE; // reset cached value
+ $reflection->setValue($this->input, FALSE); // reset cached value
$this->assertEquals('0.0.0.0', $this->input->ip_address());
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
// Proxy_ips tests
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', '127.0.0.3, 127.0.0.4, 127.0.0.2');
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2';
$this->assertEquals('127.0.0.1', $this->input->ip_address());
// Invalid spoof
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'invalid_ip_address');
$_SERVER['HTTP_CLIENT_IP'] = 'invalid_ip_address';
$this->assertEquals('127.0.0.1', $this->input->ip_address());
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1');
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1';
$this->assertEquals('127.0.0.1', $this->input->ip_address());
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.2');
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2';
$_SERVER['REMOTE_ADDR'] = '127.0.0.2';
$this->assertEquals('127.0.0.2', $this->input->ip_address());
- //IPv6
- $this->input->ip_address = FALSE;
+ // IPv6
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329/1, FE80:0000:0000:0000:0202:B3FF:FE1E:8300/2');
$_SERVER['HTTP_CLIENT_IP'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8300';
$_SERVER['REMOTE_ADDR'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329';
$this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address());
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
+ $this->ci_set_config('proxy_ips', '0::/32');
+ $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.7';
+ $_SERVER['REMOTE_ADDR'] = '0000:0000:0000:0000:0000:0000:0000:0001';
+ $this->assertEquals('127.0.0.7', $this->input->ip_address());
+
+ $reflection->setValue($this->input, FALSE);
$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality
}
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
index d2dd7598a..4958f42e1 100644
--- a/tests/codeigniter/core/Lang_test.php
+++ b/tests/codeigniter/core/Lang_test.php
@@ -34,11 +34,6 @@ class Lang_test extends CI_TestCase {
$this->assertTrue($this->lang->load('email', 'german'));
$this->assertEquals('german', $this->lang->is_loaded['email_lang.php']);
- // Non-alpha idiom (should act the same as unspecified language)
- $this->ci_vfs_clone('system/language/english/number_lang.php');
- $this->assertTrue($this->lang->load('number'));
- $this->assertEquals('Bytes', $this->lang->language['bytes']);
-
// Non-existent file
$this->setExpectedException(
'RuntimeException',
@@ -49,6 +44,23 @@ class Lang_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_non_alpha_idiom()
+ {
+ // Non-alpha idiom (should act the same as unspecified language)
+ // test with existing file
+ $this->ci_vfs_clone('system/language/english/number_lang.php');
+ $this->ci_vfs_clone('system/language/english/number_lang.php', 'system/language/123funny/');
+ $this->assertTrue($this->lang->load('number', '123funny'));
+ $this->assertEquals('Bytes', $this->lang->language['bytes']);
+
+ // test without existing file
+ $this->ci_vfs_clone('system/language/english/email_lang.php');
+ $this->assertTrue($this->lang->load('email', '456funny'));
+ $this->assertEquals('You did not specify a SMTP hostname.', $this->lang->language['email_no_hostname']);
+ }
+
+ // --------------------------------------------------------------------
+
public function test_multiple_file_load()
{
// Multiple files
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 889ab92e4..241c415b3 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -48,11 +48,9 @@ class Loader_test extends CI_TestCase {
// Test a string given to params
$this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' '));
- // Create library w/o class
- $lib = 'bad_test_lib';
- $this->ci_vfs_create($lib, '', $this->ci_base_root, 'libraries');
+ // test non existent lib
+ $lib = 'non_existent_test_lib';
- // Test non-existent class
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested class: '.ucfirst($lib)
@@ -62,6 +60,19 @@ class Loader_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_bad_library()
+ {
+ $lib = 'bad_test_lib';
+ $this->ci_vfs_create(ucfirst($lib), '', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Non-existent class: '.ucfirst($lib)
+ );
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
+ }
+
+ // --------------------------------------------------------------------
+
public function test_library_extension()
{
// Create library and extension in VFS
@@ -131,6 +142,16 @@ class Loader_test extends CI_TestCase {
// Test is_loaded
$this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib)));
+
+ // Test to load another class with the same object name
+ $lib = 'another_test_lib';
+ $class = ucfirst($lib);
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ "CI Error: Resource '".$obj."' already exists and is not a ".$class." instance."
+ );
+ $this->load->library($lib, NULL, $obj);
}
// --------------------------------------------------------------------
@@ -270,12 +291,14 @@ class Loader_test extends CI_TestCase {
$this->assertEquals($content.$value, $out);
// Mock output class
- $output = $this->getMock('CI_Output', array('append_output'));
+ $output = $this->getMockBuilder('CI_Output')->setMethods(array('append_output'))->getMock();
$output->expects($this->once())->method('append_output')->with($content.$value);
$this->ci_instance_var('output', $output);
- // Test view output
- $this->assertInstanceOf('CI_Loader', $this->load->view($view, array($var => $value)));
+ // Test view output and $vars as an object
+ $vars = new stdClass();
+ $vars->$var = $value;
+ $this->assertInstanceOf('CI_Loader', $this->load->view($view, $vars));
}
// --------------------------------------------------------------------
@@ -420,7 +443,7 @@ class Loader_test extends CI_TestCase {
{
// Mock lang class and test load call
$file = 'test';
- $lang = $this->getMock('CI_Lang', array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
$lang->expects($this->once())->method('load')->with($file);
$this->ci_instance_var('lang', $lang);
$this->assertInstanceOf('CI_Loader', $this->load->language($file));
diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php
new file mode 100644
index 000000000..d5a6fcb6b
--- /dev/null
+++ b/tests/codeigniter/core/Log_test.php
@@ -0,0 +1,63 @@
+<?php
+class Log_test extends CI_TestCase {
+
+ public function test_configuration()
+ {
+ $path = new ReflectionProperty('CI_Log', '_log_path');
+ $path->setAccessible(TRUE);
+ $threshold = new ReflectionProperty('CI_Log', '_threshold');
+ $threshold->setAccessible(TRUE);
+ $date_fmt = new ReflectionProperty('CI_Log', '_date_fmt');
+ $date_fmt->setAccessible(TRUE);
+ $file_ext = new ReflectionProperty('CI_Log', '_file_ext');
+ $file_ext->setAccessible(TRUE);
+ $file_perms = new ReflectionProperty('CI_Log', '_file_permissions');
+ $file_perms->setAccessible(TRUE);
+ $enabled = new ReflectionProperty('CI_Log', '_enabled');
+ $enabled->setAccessible(TRUE);
+
+ $this->ci_set_config('log_path', '/root/');
+ $this->ci_set_config('log_threshold', 'z');
+ $this->ci_set_config('log_date_format', 'd.m.Y');
+ $this->ci_set_config('log_file_extension', '');
+ $this->ci_set_config('log_file_permissions', '');
+ $instance = new CI_Log();
+
+ $this->assertEquals($path->getValue($instance), '/root/');
+ $this->assertEquals($threshold->getValue($instance), 1);
+ $this->assertEquals($date_fmt->getValue($instance), 'd.m.Y');
+ $this->assertEquals($file_ext->getValue($instance), 'php');
+ $this->assertEquals($file_perms->getValue($instance), 0644);
+ $this->assertEquals($enabled->getValue($instance), FALSE);
+
+ $this->ci_set_config('log_path', '');
+ $this->ci_set_config('log_threshold', '0');
+ $this->ci_set_config('log_date_format', '');
+ $this->ci_set_config('log_file_extension', '.log');
+ $this->ci_set_config('log_file_permissions', 0600);
+ $instance = new CI_Log();
+
+ $this->assertEquals($path->getValue($instance), APPPATH.'logs/');
+ $this->assertEquals($threshold->getValue($instance), 0);
+ $this->assertEquals($date_fmt->getValue($instance), 'Y-m-d H:i:s');
+ $this->assertEquals($file_ext->getValue($instance), 'log');
+ $this->assertEquals($file_perms->getValue($instance), 0600);
+ $this->assertEquals($enabled->getValue($instance), TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_format_line()
+ {
+ $this->ci_set_config('log_path', '');
+ $this->ci_set_config('log_threshold', 0);
+ $instance = new CI_Log();
+
+ $format_line = new ReflectionMethod($instance, '_format_line');
+ $format_line->setAccessible(TRUE);
+ $this->assertEquals(
+ $format_line->invoke($instance, 'LEVEL', 'Timestamp', 'Message'),
+ "LEVEL - Timestamp --> Message\n"
+ );
+ }
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index bab76dffb..4dd31f4b1 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -12,7 +12,8 @@ class Security_test extends CI_TestCase {
$this->ci_set_config('csrf_token_name', 'ci_csrf_token');
$this->ci_set_config('csrf_cookie_name', 'ci_csrf_cookie');
- $this->security = new Mock_Core_Security();
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $this->security = new Mock_Core_Security('UTF-8');
}
// --------------------------------------------------------------------
@@ -96,7 +97,7 @@ class Security_test extends CI_TestCase {
$xss_clean_return = $this->security->xss_clean($harm_string, TRUE);
- $this->assertTrue($xss_clean_return);
+// $this->assertTrue($xss_clean_return);
}
// --------------------------------------------------------------------
@@ -115,7 +116,18 @@ class Security_test extends CI_TestCase {
public function test_xss_clean_entity_double_encoded()
{
$input = '<a href="&#38&#35&#49&#48&#54&#38&#35&#57&#55&#38&#35&#49&#49&#56&#38&#35&#57&#55&#38&#35&#49&#49&#53&#38&#35&#57&#57&#38&#35&#49&#49&#52&#38&#35&#49&#48&#53&#38&#35&#49&#49&#50&#38&#35&#49&#49&#54&#38&#35&#53&#56&#38&#35&#57&#57&#38&#35&#49&#49&#49&#38&#35&#49&#49&#48&#38&#35&#49&#48&#50&#38&#35&#49&#48&#53&#38&#35&#49&#49&#52&#38&#35&#49&#48&#57&#38&#35&#52&#48&#38&#35&#52&#57&#38&#35&#52&#49">Clickhere</a>';
- $this->assertEquals('<a >Clickhere</a>', $this->security->xss_clean($input));
+ $this->assertEquals('<a>Clickhere</a>', $this->security->xss_clean($input));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function text_xss_clean_js_link_removal()
+ {
+ // This one is to prevent a false positive
+ $this->assertEquals(
+ "<a href=\"javascrip\n<t\n:alert\n&#40;1&#41;\"\n>",
+ $this->security->xss_clean("<a href=\"javascrip\n<t\n:alert\n(1)\"\n>")
+ );
}
// --------------------------------------------------------------------
@@ -123,29 +135,113 @@ class Security_test extends CI_TestCase {
public function test_xss_clean_js_img_removal()
{
$input = '<img src="&#38&#35&#49&#48&#54&#38&#35&#57&#55&#38&#35&#49&#49&#56&#38&#35&#57&#55&#38&#35&#49&#49&#53&#38&#35&#57&#57&#38&#35&#49&#49&#52&#38&#35&#49&#48&#53&#38&#35&#49&#49&#50&#38&#35&#49&#49&#54&#38&#35&#53&#56&#38&#35&#57&#57&#38&#35&#49&#49&#49&#38&#35&#49&#49&#48&#38&#35&#49&#48&#50&#38&#35&#49&#48&#53&#38&#35&#49&#49&#52&#38&#35&#49&#48&#57&#38&#35&#52&#48&#38&#35&#52&#57&#38&#35&#52&#49">Clickhere';
- $this->assertEquals('<img >', $this->security->xss_clean($input));
+ $this->assertEquals('<img>', $this->security->xss_clean($input));
}
// --------------------------------------------------------------------
- public function test_xss_clean_sanitize_naughty_html()
+ public function test_xss_clean_sanitize_naughty_html_tags()
{
- $input = '<blink>';
- $this->assertEquals('&lt;blink&gt;', $this->security->xss_clean($input));
+ $this->assertEquals('&lt;unclosedTag', $this->security->xss_clean('<unclosedTag'));
+ $this->assertEquals('&lt;blink&gt;', $this->security->xss_clean('<blink>'));
+ $this->assertEquals('<fubar>', $this->security->xss_clean('<fubar>'));
+
+ $this->assertEquals(
+ '<img svg=""> src="x">',
+ $this->security->xss_clean('<img <svg=""> src="x">')
+ );
+
+ $this->assertEquals(
+ '<img src="b on=">on=">"x onerror="alert&#40;1&#41;">',
+ $this->security->xss_clean('<img src="b on="<x">on=">"x onerror="alert(1)">')
+ );
+
+ $this->assertEquals(
+ "\n>&lt;!-\n<b d=\"'e><iframe onload=alert&#40;1&#41; src=x>\n<a HREF=\">\n",
+ $this->security->xss_clean("\n><!-\n<b\n<c d=\"'e><iframe onload=alert(1) src=x>\n<a HREF=\"\">\n")
+ );
}
// --------------------------------------------------------------------
- public function test_remove_evil_attributes()
+ public function test_xss_clean_sanitize_naughty_html_attributes()
{
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo onAttribute="bar">', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo onAttributeNoQuotes=bar>', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo onAttributeWithSpaces = bar>', FALSE));
- $this->assertEquals('<foo prefixOnAttribute="bar">', $this->security->remove_evil_attributes('<foo prefixOnAttribute="bar">', FALSE));
- $this->assertEquals('<foo>onOutsideOfTag=test</foo>', $this->security->remove_evil_attributes('<foo>onOutsideOfTag=test</foo>', FALSE));
- $this->assertEquals('onNoTagAtAll = true', $this->security->remove_evil_attributes('onNoTagAtAll = true', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo fscommand=case-insensitive>', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo seekSegmentTime=whatever>', FALSE));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttribute="bar">'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttributeNoQuotes=bar>'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttributeWithSpaces = bar>'));
+ $this->assertEquals('<foo prefixOnAttribute="bar">', $this->security->xss_clean('<foo prefixOnAttribute="bar">'));
+ $this->assertEquals('<foo>onOutsideOfTag=test</foo>', $this->security->xss_clean('<foo>onOutsideOfTag=test</foo>'));
+ $this->assertEquals('onNoTagAtAll = true', $this->security->xss_clean('onNoTagAtAll = true'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo fscommand=case-insensitive>'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo seekSegmentTime=whatever>'));
+
+ $this->assertEquals(
+ '<foo bar=">" baz=\'>\' xss=removed>',
+ $this->security->xss_clean('<foo bar=">" baz=\'>\' onAfterGreaterThan="quotes">')
+ );
+ $this->assertEquals(
+ '<foo bar=">" baz=\'>\' xss=removed>',
+ $this->security->xss_clean('<foo bar=">" baz=\'>\' onAfterGreaterThan=noQuotes>')
+ );
+
+ $this->assertEquals(
+ '<img src="x" on=""> on=&lt;svg&gt; onerror=alert&#40;1&#41;>',
+ $this->security->xss_clean('<img src="x" on=""> on=<svg> onerror=alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<img src="on=\'">"&lt;svg&gt; onerror=alert&#40;1&#41; onmouseover=alert&#40;1&#41;>',
+ $this->security->xss_clean('<img src="on=\'">"<svg> onerror=alert(1) onmouseover=alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<img src="x"> on=\'x\' onerror=``,alert&#40;1&#41;>',
+ $this->security->xss_clean('<img src="x"> on=\'x\' onerror=``,alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<a xss=removed>',
+ $this->security->xss_clean('<a< onmouseover="alert(1)">')
+ );
+
+ $this->assertEquals(
+ '<img src="x"> on=\'x\' onerror=,xssm()>',
+ $this->security->xss_clean('<img src="x"> on=\'x\' onerror=,xssm()>')
+ );
+
+ $this->assertEquals(
+ '<image src="<>" xss=removed>',
+ $this->security->xss_clean('<image src="<>" onerror=\'alert(1)\'>')
+ );
+
+ $this->assertEquals(
+ '<b xss=removed>',
+ $this->security->xss_clean('<b "=<= onmouseover=alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<b xss=removed xss=removed>1">',
+ $this->security->xss_clean('<b a=<=" onmouseover="alert(1),1>1">')
+ );
+
+ $this->assertEquals(
+ '<b x=" onmouseover=alert&#40;1&#41;//">',
+ $this->security->xss_clean('<b "="< x=" onmouseover=alert(1)//">')
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * @depends test_xss_clean_sanitize_naughty_html_tags
+ * @depends test_xss_clean_sanitize_naughty_html_attributes
+ */
+ public function test_naughty_html_plus_evil_attributes()
+ {
+ $this->assertEquals(
+ '&lt;svg<img src="x" xss=removed>',
+ $this->security->xss_clean('<svg<img > src="x" onerror="location=/javascript/.source+/:alert/.source+/(1)/.source">')
+ );
}
// --------------------------------------------------------------------
@@ -180,6 +276,12 @@ class Security_test extends CI_TestCase {
$this->assertEquals('<div>Hello <b>Booya</b></div>', $decoded);
+ $this->assertEquals('colon:', $this->security->entity_decode('colon&colon;'));
+ $this->assertEquals("NewLine\n", $this->security->entity_decode('NewLine&NewLine;'));
+ $this->assertEquals("Tab\t", $this->security->entity_decode('Tab&Tab;'));
+ $this->assertEquals("lpar(", $this->security->entity_decode('lpar&lpar;'));
+ $this->assertEquals("rpar)", $this->security->entity_decode('rpar&rpar;'));
+
// Issue #3057 (https://github.com/bcit-ci/CodeIgniter/issues/3057)
$this->assertEquals(
'&foo should not include a semicolon',
@@ -209,7 +311,8 @@ class Security_test extends CI_TestCase {
'<img src="mdn-logo-sm.png" alt="MD Logo" srcset="mdn-logo-HD.png 2x, mdn-logo-small.png 15w, mdn-banner-HD.png 100w 2x" />',
'<img sqrc="/img/sunset.gif" height="100%" width="100%">',
'<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">'
+ '<img srcq="/img/sunset.gif" height="100%" width="100%">',
+ '<img src=non-quoted.attribute foo="bar">'
);
$urls = array(
@@ -220,7 +323,8 @@ class Security_test extends CI_TestCase {
'mdn-logo-sm.png',
'<img sqrc="/img/sunset.gif" height="100%" width="100%">',
'<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">'
+ '<img srcq="/img/sunset.gif" height="100%" width="100%">',
+ 'non-quoted.attribute'
);
for ($i = 0; $i < count($imgtags); $i++)
@@ -243,7 +347,7 @@ class Security_test extends CI_TestCase {
// leave csrf_cookie_name as blank to test _csrf_set_hash function
$this->ci_set_config('csrf_cookie_name', '');
- $this->security = new Mock_Core_Security();
+ $this->security = new Mock_Core_Security('UTF-8');
$this->assertNotEmpty($this->security->get_csrf_hash());
}
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 42dff3639..f862c666e 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -119,8 +119,13 @@ class URI_test extends CI_TestCase {
*/
// --------------------------------------------------------------------
+ /**
+ * @runInSeparateProcess
+ */
public function test_filter_uri_passing()
{
+ define('UTF8_ENABLED', FALSE);
+
$this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
$str = 'abc01239~%.:_-';
@@ -129,8 +134,12 @@ class URI_test extends CI_TestCase {
// --------------------------------------------------------------------
+ /**
+ * @runInSeparateProcess
+ */
public function test_filter_uri_throws_error()
{
+ define('UTF8_ENABLED', FALSE);
$this->setExpectedException('RuntimeException');
$this->uri->config->set_item('enable_query_strings', FALSE);
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
index 7e6ffd930..f40bb9848 100644
--- a/tests/codeigniter/core/Utf8_test.php
+++ b/tests/codeigniter/core/Utf8_test.php
@@ -1,31 +1,27 @@
<?php
+/**
+ * @runTestsInSeparateProcesses
+ */
class Utf8_test extends CI_TestCase {
- public function set_up()
+ public function test___constructUTF8_ENABLED()
{
- $this->ci_set_config('charset', 'UTF-8');
- $this->utf8 = new Mock_Core_Utf8();
- $this->ci_instance_var('utf8', $this->utf8);
+ if ( ! defined('PREG_BAD_UTF8_ERROR') OR (ICONV_ENABLED === FALSE && MB_ENABLED === FALSE))
+ {
+ return $this->markTestSkipped('PCRE_UTF8 and/or both ext/mbstring & ext/iconv are unavailable');
+ }
+
+ new CI_Utf8('UTF-8');
+ $this->assertTrue(UTF8_ENABLED);
}
// --------------------------------------------------------------------
- /**
- * __construct() test
- *
- * @covers CI_Utf8::__construct
- */
- public function test___construct()
+ public function test__constructUTF8_DISABLED()
{
- if (defined('PREG_BAD_UTF8_ERROR') && (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) && strtoupper(config_item('charset')) === 'UTF-8')
- {
- $this->assertTrue(UTF8_ENABLED);
- }
- else
- {
- $this->assertFalse(UTF8_ENABLED);
- }
+ new CI_Utf8('WINDOWS-1251');
+ $this->assertFalse(UTF8_ENABLED);
}
// --------------------------------------------------------------------
@@ -37,8 +33,9 @@ class Utf8_test extends CI_TestCase {
*/
public function test_is_ascii()
{
- $this->assertTrue($this->utf8->is_ascii('foo bar'));
- $this->assertFalse($this->utf8->is_ascii('тест'));
+ $utf8 = new CI_Utf8('UTF-8');
+ $this->assertTrue($utf8->is_ascii('foo bar'));
+ $this->assertFalse($utf8->is_ascii('тест'));
}
// --------------------------------------------------------------------
@@ -51,21 +48,22 @@ class Utf8_test extends CI_TestCase {
*/
public function test_clean_string()
{
- $this->assertEquals('foo bar', $this->utf8->clean_string('foo bar'));
+ $utf8 = new CI_Utf8('UTF-8');
+ $this->assertEquals('foo bar', $utf8->clean_string('foo bar'));
$illegal_utf8 = "\xc0тест";
if (MB_ENABLED)
{
- $this->assertEquals('тест', $this->utf8->clean_string($illegal_utf8));
+ $this->assertEquals('тест', $utf8->clean_string($illegal_utf8));
}
elseif (ICONV_ENABLED)
{
// This is a known issue, iconv doesn't always work with //IGNORE
- $this->assertTrue(in_array($this->utf8->clean_string($illegal_utf8), array('тест', ''), TRUE));
+ $this->assertTrue(in_array($utf8->clean_string($illegal_utf8), array('тест', ''), TRUE));
}
else
{
- $this->assertEquals($illegal_utf8, $this->utf8->clean_string($illegal_utf8));
+ $this->assertEquals($illegal_utf8, $utf8->clean_string($illegal_utf8));
}
}
@@ -78,14 +76,15 @@ class Utf8_test extends CI_TestCase {
*/
public function test_convert_to_utf8()
{
+ $utf8 = new CI_Utf8('UTF-8');
if (MB_ENABLED OR ICONV_ENABLED)
{
- $this->assertEquals('тест', $this->utf8->convert_to_utf8('', 'WINDOWS-1251'));
+ $this->assertEquals('тест', $utf8->convert_to_utf8('', 'WINDOWS-1251'));
}
else
{
- $this->assertFalse($this->utf8->convert_to_utf8('', 'WINDOWS-1251'));
+ $this->assertFalse($utf8->convert_to_utf8('', 'WINDOWS-1251'));
}
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php
index 8a507d14a..77f5eba4e 100644
--- a/tests/codeigniter/core/compat/password_test.php
+++ b/tests/codeigniter/core/compat/password_test.php
@@ -8,11 +8,6 @@ class password_test extends CI_TestCase {
{
return $this->markTestSkipped('ext/standard/password is available on PHP 5.5');
}
- elseif ( ! is_php('5.3.7'))
- {
- $this->assertFalse(defined('PASSWORD_BCRYPT'));
- return $this->markTestSkipped("PHP versions prior to 5.3.7 don't have the '2y' Blowfish version");
- }
// defined as of HHVM 2.3.0, which is also when they introduce password_*() as well
// Note: Do NOT move this after the CRYPT_BLOWFISH check
elseif (defined('HHVM_VERSION'))
diff --git a/tests/codeigniter/core/compat/standard_test.php b/tests/codeigniter/core/compat/standard_test.php
index 4077a5c7c..54424bb9b 100644
--- a/tests/codeigniter/core/compat/standard_test.php
+++ b/tests/codeigniter/core/compat/standard_test.php
@@ -10,18 +10,6 @@ class standard_test extends CI_TestCase {
}
$this->assertTrue(function_exists('array_column'));
-
- if ( ! is_php('5.4'))
- {
- $this->assertTrue(function_exists('hex2bin'));
- }
-
- if ( ! is_php('5.3'))
- {
- $this->assertTrue(function_exists('array_replace'));
- $this->assertTrue(function_exists('array_replace_recursive'));
- $this->assertTrue(function_exists('quoted_printable_encode'));
- }
}
// ------------------------------------------------------------------------
@@ -337,212 +325,6 @@ class standard_test extends CI_TestCase {
array_column($input, 'b', 'a')
);
}
-
- // ------------------------------------------------------------------------
-
- /**
- * hex2bin() tests
- *
- * @depends test_bootstrap
- */
- public function test_hex2bin()
- {
- if (is_php('5.4'))
- {
- return $this->markTestSkipped('hex2bin() is already available on PHP 5.4');
- }
-
- $this->assertEquals("\x03\x04", hex2bin("0304"));
- $this->assertEquals('', hex2bin(''));
- $this->assertEquals("\x01\x02\x03", hex2bin(new FooHex()));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * array_replace(), array_replace_recursive() tests
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_array_replace_recursive()
- {
- if (is_php('5.3'))
- {
- return $this->markTestSkipped('array_replace() and array_replace_recursive() are already available on PHP 5.3');
- }
-
- $array1 = array(
- 0 => 'dontclobber',
- '1' => 'unclobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => TRUE,
- 1 => array(
- 'testsubarray1' => 'dontclobber2',
- 'testsubarray2' => 'dontclobber3'
- )
- )
- );
-
- $array2 = array(
- 1 => 'clobbered',
- 'test3' => array(
- 'testarray2' => FALSE
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- );
-
- // array_replace()
- $this->assertEquals(
- array(
- 0 => 'dontclobber',
- 1 => 'clobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => FALSE
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- ),
- array_replace($array1, $array2)
- );
-
- // array_replace_recursive()
- $this->assertEquals(
- array(
- 0 => 'dontclobber',
- 1 => 'clobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => FALSE,
- 1 => array(
- 'testsubarray1' => 'dontclobber2',
- 'testsubarray2' => 'dontclobber3'
- )
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- ),
- array_replace_recursive($array1, $array2)
- );
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * quoted_printable_encode() tests
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_quoted_printable_encode()
- {
- if (is_php('5.3'))
- {
- return $this->markTestSkipped('quoted_printable_encode() is already available on PHP 5.3');
- }
-
- // These are actually imap_8bit() tests:
- $this->assertEquals("String with CRLF at end=20\r\n", quoted_printable_encode("String with CRLF at end \r\n"));
- // ext/imap/tests/imap_8bit_basic.phpt says for this line:
- // NB this appears to be a bug in cclient; a space at end of string should be encoded as =20
- $this->assertEquals("String with space at end ", quoted_printable_encode("String with space at end "));
- $this->assertEquals("String with tabs =09=09 in middle", quoted_printable_encode("String with tabs \t\t in middle"));
- $this->assertEquals("String with tab at end =09", quoted_printable_encode("String with tab at end \t"));
- $this->assertEquals("=00=01=02=03=04=FE=FF=0A=0D", quoted_printable_encode("\x00\x01\x02\x03\x04\xfe\xff\x0a\x0d"));
-
- if (function_exists('imap_8bit'))
- {
- return $this->markTestIncomplete('imap_8bit() exists and is called as an alias for quoted_printable_encode()');
- }
-
- // And these are from ext/standard/tests/strings/quoted_printable_encode_002.phpt:
- $this->assertEquals(
- "=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00",
- $d = quoted_printable_encode(str_repeat("\0", 200))
- );
- $this->assertEquals(str_repeat("\x0", 200), quoted_printable_decode($d));
- $this->assertEquals(
- "=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 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=D1=8E=D0=BD=D0=B8=D0=\r\n"
- ."=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=\r\n"
- ."=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =\r\n"
- ."=D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=\r\n"
- ."=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=\r\n"
- ."=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=\r\n"
- ."=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=\r\n"
- ."=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=\r\n"
- ."=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5",
- $d = quoted_printable_encode(str_repeat('строка в юникоде', 50))
- );
- $this->assertEquals(str_repeat('строка в юникоде', 50), quoted_printable_decode($d));
- $this->assertEquals('this is a foo', quoted_printable_encode(new FooObject()));
- }
}
// ------------------------------------------------------------------------
@@ -562,19 +344,3 @@ class Bar {
return 'first_name';
}
}
-
-class FooHex {
-
- public function __toString()
- {
- return '010203';
- }
-}
-
-class FooObject
-{
- public function __toString()
- {
- return 'this is a foo';
- }
-} \ No newline at end of file