Skip to content

Commit

Permalink
Merge pull request #1569 from natanfelles/common
Browse files Browse the repository at this point in the history
Test esc() with different encodings and ignore app-only helpers
  • Loading branch information
lonnieezell authored Dec 3, 2018
2 parents e326916 + f91b3e0 commit 95b599d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ function helper($filenames)
{
if (strpos($path, APPPATH) === 0)
{
// @codeCoverageIgnoreStart
$appHelper = $path;
// @codeCoverageIgnoreEnd
}
elseif (strpos($path, BASEPATH) === 0)
{
Expand All @@ -597,7 +599,9 @@ function helper($filenames)
// App-level helpers should override all others
if (! empty($appHelper))
{
// @codeCoverageIgnoreStart
$includes[] = $appHelper;
// @codeCoverageIgnoreEnd
}

// All namespaced files get added in next
Expand Down
9 changes: 9 additions & 0 deletions tests/system/CommonFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ public function testViewCell()

// ------------------------------------------------------------------------

public function testEscapeWithDifferentEncodings()
{
$this->assertEquals('&lt;x', esc('<x', 'html', 'utf-8'));
$this->assertEquals('&lt;x', esc('<x', 'html', 'iso-8859-1'));
$this->assertEquals('&lt;x', esc('<x', 'html', 'windows-1251'));
}

// ------------------------------------------------------------------------

public function testEscapeBadContext()
{
$this->expectException(InvalidArgumentException::class);
Expand Down

0 comments on commit 95b599d

Please sign in to comment.