rancoud / security
Security package
Installs: 8 095
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=7.4.0
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16 || ^3.0
- phpunit/phpunit: ^9.1 || ^10.0 || ^11.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-11-19 12:39:22 UTC
README
Escape string to output HTML (and JS).
Installation
composer require rancoud/security
How to use it?
Security::escAttr('string'); Security::escHTML('string'); Security::escJS('string'); Security::escURL('string'); Security::escCSS('string'); Security::isSupportedCharset('string');
Supported Charsets
Charsets supported are only charsets shortlisted (see list below) which are also supported by mbstring extension.
More info at PHP documentation
And at the PHP libmbfl README
Charsets shortlisted:
- ISO-8859-1
- ISO-8859-5
- ISO-8859-15
- UTF-8
- cp866
- cp1251
- cp1252
- KOI8-R
- BIG5
- GB2312
- BIG5-HKSCS
- Shift_JIS
- EUC-JP
- MacRoman
Security Methods
General Static Methods
- isSupportedCharset(charset: string): bool
- areCharsetAliases(charsetToCheck: string, charsetReference: string): bool
- escHTML(text: mixed, [charset: string = 'UTF-8']): string
- escAttr(text: mixed, [charset: string = 'UTF-8']): string
- escJS(text: mixed, [charset: string = 'UTF-8']): string
- escURL(text: mixed, [charset: string = 'UTF-8']): string
- escCSS(text: mixed, [charset: string = 'UTF-8']): string
How to Dev
composer ci
for php-cs-fixer and phpunit and coverage
composer lint
for php-cs-fixer
composer test
for phpunit and coverage