-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nguyenanhung/v2.x
Release v2.0.5
- Loading branch information
Showing
2 changed files
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ function is_php($version): bool | |
* | ||
* @param mixed $string | ||
* | ||
* @return string|null | ||
* @return mixed | ||
*/ | ||
function escapeHtml($string) | ||
{ | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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 | ||
{ | ||
|
@@ -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); | ||
|
@@ -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 | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
*/ | ||
class Escape | ||
{ | ||
const VERSION = '2.0.4'; | ||
const VERSION = '2.0.5'; | ||
|
||
/** | ||
* Character set | ||
|
@@ -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'); | ||
|
||
|
@@ -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); | ||
|
@@ -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'); | ||
|
||
|
@@ -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'); | ||
|
||
|
@@ -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'); | ||
|
||
|
@@ -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'); | ||
|
||
|
@@ -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)) { | ||
|