Skip to content

Commit

Permalink
Merge pull request #7 from nguyenanhung/v2.x
Browse files Browse the repository at this point in the history
Release v2.0.5
  • Loading branch information
nguyenanhung authored Aug 2, 2023
2 parents 8b0250e + 74e37a9 commit ee007ad
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
70 changes: 35 additions & 35 deletions helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function is_php($version): bool
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
function escapeHtml($string)
{
Expand All @@ -56,15 +56,15 @@ function escapeHtml($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 09/21/2021 00:05
*/
function htmlEscape($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeHtml($string);
Expand All @@ -79,12 +79,12 @@ function htmlEscape($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
function escapeHtmlAttr($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeHtmlAttribute($string);
Expand All @@ -96,15 +96,15 @@ function escapeHtmlAttr($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 09/23/2021 44:34
*/
function escapeHtmlAttribute($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeHtmlAttribute($string);
Expand All @@ -119,12 +119,12 @@ function escapeHtmlAttribute($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
function escapeJs($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeJs($string);
Expand All @@ -143,8 +143,8 @@ function escapeJs($string)
*/
function escapeInputVar($var)
{
if ($var === null) {
return null;
if (empty($var)) {
return $var;
}

return (new Escape())->escapeInput($var);
Expand Down Expand Up @@ -172,15 +172,15 @@ function escape_input_var($var)
*
* @param mixed $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 09/20/2021 58:14
*/
function escapeCss($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeCss($string);
Expand All @@ -195,12 +195,12 @@ function escapeCss($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
function escapeUrl($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeUrl($string);
Expand All @@ -216,7 +216,7 @@ function escapeUrl($string)
* @param mixed $str
* @param bool $urlEncoded
*
* @return string|null
* @return mixed
*/
function removeInvisibleCharacters($str, bool $urlEncoded = true): string
{
Expand All @@ -229,15 +229,15 @@ function removeInvisibleCharacters($str, bool $urlEncoded = true): string
*
* @param $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 05/25/2021 58:03
*/
function escape_html($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeHtml($string);
Expand All @@ -249,7 +249,7 @@ function escape_html($string)
*
* @param $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 05/25/2021 58:41
Expand All @@ -265,15 +265,15 @@ function escape_html_attribute($string): string
*
* @param $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 05/25/2021 59:04
*/
function escape_js($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeJs($string);
Expand All @@ -285,15 +285,15 @@ function escape_js($string)
*
* @param $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 05/25/2021 59:24
*/
function escape_css($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeCss($string);
Expand All @@ -305,15 +305,15 @@ function escape_css($string)
*
* @param $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 05/25/2021 59:40
*/
function escape_url($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return (new Escape())->escapeUrl($string);
Expand Down
42 changes: 21 additions & 21 deletions src/Escape.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class Escape
{
const VERSION = '2.0.4';
const VERSION = '2.0.5';

/**
* Character set
Expand Down Expand Up @@ -348,12 +348,12 @@ public function sanitizeFilename($str, bool $relative_path = false): string
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
public function escapeHtml($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}
$escape = new Escaper('utf-8');

Expand All @@ -365,15 +365,15 @@ public function escapeHtml($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 09/21/2021 00:05
*/
public function htmlEscape($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}

return $this->escapeHtml($string);
Expand All @@ -387,12 +387,12 @@ public function htmlEscape($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
public function escapeHtmlAttribute($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}
$escape = new Escaper('utf-8');

Expand All @@ -407,12 +407,12 @@ public function escapeHtmlAttribute($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
public function escapeJs($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}
$escape = new Escaper('utf-8');

Expand All @@ -424,15 +424,15 @@ public function escapeJs($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 09/20/2021 58:14
*/
public function escapeCss($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}
$escape = new Escaper('utf-8');

Expand All @@ -447,12 +447,12 @@ public function escapeCss($string)
*
* @param mixed $string
*
* @return string|null
* @return mixed
*/
public function escapeUrl($string)
{
if ($string === null) {
return null;
if (empty($string)) {
return $string;
}
$escape = new Escaper('utf-8');

Expand Down Expand Up @@ -501,8 +501,8 @@ public function removeInvisibleCharacters($str, bool $urlEncoded = true): string
*/
public function escapeInput($var)
{
if (is_null($var)) {
return null;
if (empty($var)) {
return $var;
}
if (is_string($var)) {
if ($this->isJson($var)) {
Expand Down

0 comments on commit ee007ad

Please sign in to comment.