Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Oct 21, 2015
2 parents d643a84 + 574d069 commit c7d68ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
}
}
}
16 changes: 6 additions & 10 deletions src/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ class Escaper

/**
* Holds the value of the special flags passed as second parameter to
* htmlspecialchars(). We modify these for PHP 5.4 to take advantage
* of the new ENT_SUBSTITUTE flag for correctly dealing with invalid
* UTF-8 sequences.
* htmlspecialchars().
*
* @var string
* @var int
*/
protected $htmlSpecialCharsFlags = ENT_QUOTES;
protected $htmlSpecialCharsFlags;

/**
* Static Matcher which escapes characters for HTML Attribute contexts
Expand Down Expand Up @@ -89,8 +87,7 @@ class Escaper

/**
* Constructor: Single parameter allows setting of global encoding for use by
* the current object. If PHP 5.4 is detected, additional ENT_SUBSTITUTE flag
* is set for htmlspecialchars() calls.
* the current object.
*
* @param string $encoding
* @throws Exception\InvalidArgumentException
Expand All @@ -116,9 +113,8 @@ public function __construct($encoding = null)
$this->encoding = $encoding;
}

if (defined('ENT_SUBSTITUTE')) {
$this->htmlSpecialCharsFlags|= ENT_SUBSTITUTE;
}
// We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences.
$this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE;

// set matcher callbacks
$this->htmlAttrMatcher = [$this, 'htmlAttrMatcher'];
Expand Down

0 comments on commit c7d68ca

Please sign in to comment.