Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rancoud/security
Security Package
https://github.com/rancoud/security
charset composer coverage escaper packagist php php74 php8 php80 php81 phpunit phpunit9 security
Last synced: 2 months ago
JSON representation
Security Package
- Host: GitHub
- URL: https://github.com/rancoud/security
- Owner: rancoud
- License: mit
- Created: 2018-10-22T06:50:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-06T20:37:07.000Z (2 months ago)
- Last Synced: 2024-11-09T08:03:25.583Z (2 months ago)
- Topics: charset, composer, coverage, escaper, packagist, php, php74, php8, php80, php81, phpunit, phpunit9, security
- Language: PHP
- Homepage: https://packagist.org/packages/rancoud/security
- Size: 360 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Security Package
![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/rancoud/security)
[![Packagist Version](https://img.shields.io/packagist/v/rancoud/security)](https://packagist.org/packages/rancoud/security)
[![Packagist Downloads](https://img.shields.io/packagist/dt/rancoud/security)](https://packagist.org/packages/rancoud/security)
[![Composer dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://github.com/rancoud/Security/blob/master/composer.json)
[![Test workflow](https://img.shields.io/github/actions/workflow/status/rancoud/security/test.yml?branch=master)](https://github.com/rancoud/security/actions/workflows/test.yml)
[![Codecov](https://img.shields.io/codecov/c/github/rancoud/security?logo=codecov)](https://codecov.io/gh/rancoud/security)Escape string to output HTML (and JS).
## Installation
```php
composer require rancoud/security
```## How to use it?
```php
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](https://www.php.net/manual/en/mbstring.encodings.php)
[And at the PHP libmbfl README](https://github.com/php/php-src/tree/master/ext/mbstring/libmbfl)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