summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-03-06 11:32:49 +0100
committerAndrey Andreev <narf@devilix.net>2015-03-06 11:32:49 +0100
commit3b526f46f5f28bc15a3402a895538777056cc9f3 (patch)
treeec7b82ec0d2963d9a2014e7fc1c9afd57b56e9fe /tests/codeigniter
parent137aa20e0b0fd71ff8f672c57c07c4972c91c6a4 (diff)
parent588a0e3774d1397b9cd0b5f9d0ba2f4793243267 (diff)
Merge pull request #3644 from ahnh/CI_Security_test
Add unit test for CI_Security::strip_image_tags()
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/core/Security_test.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index d967613b5..c96eecf02 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -126,5 +126,36 @@ class Security_test extends CI_TestCase {
$this->assertEquals('foo', $safe_filename);
}
+
+ // --------------------------------------------------------------------
+ public function test_strip_image_tags()
+ {
+ $imgtags = Array(
+ '<img src="smiley.gif" alt="Smiley face" height="42" width="42">',
+ '<img alt="Smiley face" height="42" width="42" src="smiley.gif">',
+ '<img src="http://www.w3schools.com/images/w3schools_green.jpg">',
+ '<img src="/img/sunset.gif" height="100%" width="100%">',
+ '<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%">'
+ );
+
+ $urls = Array(
+ 'smiley.gif',
+ 'smiley.gif',
+ 'http://www.w3schools.com/images/w3schools_green.jpg',
+ '/img/sunset.gif',
+ '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%">'
+ );
+
+ for($i = 0; $i < count($imgtags); $i++)
+ {
+ $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i]));
+ }
+ }
} \ No newline at end of file