PHPackages                             rfuehricht/sanitizegp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. rfuehricht/sanitizegp

ActiveTypo3-cms-extension[Validation &amp; Sanitization](/categories/validation)

rfuehricht/sanitizegp
=====================

Globally configure sanitizing actions for GET/POST parameters.

1.0.0(1y ago)0358↓50%GPL-3.0-or-laterPHPPHP ^8.1

Since Mar 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rfuehricht/sanitizegp)[ Packagist](https://packagist.org/packages/rfuehricht/sanitizegp)[ RSS](/packages/rfuehricht-sanitizegp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

EXT:sanitizegp - Sanitize GET/POST values
=========================================

[](#extsanitizegp---sanitize-getpost-values)

This extension makes it possible to configure global rules for GET/POST parameters to sanitize or convert them. This way you can ensure that basic checks are applied and integer values are converted to integer and so on.

How to configure
----------------

[](#how-to-configure)

Configuration is done via site settings.

```
sanitizegp:
  L:
    - action: convert
      type: int
    - action: range
      lower: 0
      upper: 3
  parameter1:
    - action: htmlSpecialChars
  tx_news|news:
    - action: int
```

Use pipe notation to access deep array parameters. You can use wildcard `*` to access all deep values. Use keyword `all` to perform actions on **all** parameters.

Examples:

```
array|*:
- action: range
  lower: 1
  upper: 3
```

Parameters `array[sub]=27&array[sub2]=27&array[sub3][sub1]=27` will all be handled and result in `3` as configured as `upper` limit.

Perform actions on **all** parameters:

```
all:
- action: htmlSpecialChars
```

Global Settings
---------------

[](#global-settings)

```
sanitizegp:
  settings:
    separator: '.'
    replaceGlobals: 1
```

### Available settings

[](#available-settings)

`separator` is the separator to use for accessing deep array values. Default is `|`.

`replaceGlobals` specifies if `$_GET` and `$_POST` should be replaced with the sanitized values or be left untouched. By default, only the values in the request object are sanitized.

Available Actions
-----------------

[](#available-actions)

Each action has the option `scope` to define if only `get` or `post`should be processed. Default is `get` **and** `post`.

```
- action: convert
  type: int
  scope:
    - get
    - post
```

### Convert

[](#convert)

Converts value to a specific data type.

#### Options

[](#options)

`type` Currently, can be `int` or `float`.

### HtmlSpecialChars

[](#htmlspecialchars)

Calls `htmlspecialchars` on the value.

### Length

[](#length)

Makes sure a string value is in a length range.

If only one limit is set, the other one is ignored.

If value is shorter than `min`, the values is filled with content set in `padString` using PHP function `str_pad` ().

#### Options

[](#options-1)

`min` The lower length limit.

`max` The upper length limit.

`padString` The content to fill up value shorter than `min`.

`padType` Where to apply `padString`. Can be: `left`, `right`, `both`. Default is `right`.

### Range

[](#range)

Makes sure a numeric value is in a certain range. If value is out of range, it will be set to the lower/upper as defined.

If only one limit is set, the other one is ignored.

#### Options

[](#options-2)

`lower` The lower range limit.

`upper` The upper range limit.

### Replace

[](#replace)

Replaces values in the value.

#### Options

[](#options-3)

`search` Array or comma separated list of values to search.

`replace` Array or comma separated list of replacements.

`replaceFunction` Defaults to `str_ireplace`. Can be: `str_replace`, `str_ireplace`or `preg_replace`. When using `preg_replace`, the search and replacements are not exploded by the separator. Each line is treated as a regular expression.

`separator` Specify custom separator for values in `search` and `replace`. Default is `,`.

`fileSource` Path to file (absolute or relative from project root) containing the search/replacement infos.

**Examples**

Simple:

```
- action: replace
  search: 'foo,bar,baz'
  replace: 'hello,world,!'
  fileSource: 'config/replacements.txt'
```

`replacements.txt` has this format:

```
foo,bar,baz => hello
bad => good
i love dogs => i love cats

```

Replacements from file are added to the list defined in `search` and `replace`.

Replacements as arrays:

```
- action: replace
  search:
    - 'foo,bar,baz'
    - 'bad word'
  replace:
    - 'hello'
    - 'good word'
  fileSource: 'config/replacements.txt'
```

This replaces `foo`, `bar` and `baz` with `hello` and `good word` with `bad word`

Replacement with `preg_replace`:

```
- action: replace
  replaceFunction: 'preg_replace'
  search:
    - '/foo.*bar/i'
    - '#bad word#i'
    - '/i am (.+)/i'
  replace:
    - 'foobar'
    - 'good word'
    - 'my name is $1'
```

### StripTags

[](#striptags)

Calls `strip_tags` on the value.

#### Options

[](#options-4)

`allowedTags` Array of tags to keep

Example:

```
- action: StripTags
  options:
    allowedTags:
      - b
      - strong
      - i
      - em
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance45

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

429d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/67321c806c6cfdcc7cefb65bb80859480391e2f3f3b075144038f97bce1a43c9?d=identicon)[rfuehricht](/maintainers/rfuehricht)

---

Top Contributors

[![rfuehricht](https://avatars.githubusercontent.com/u/144118058?v=4)](https://github.com/rfuehricht "rfuehricht (11 commits)")

### Embed Badge

![Health badge](/badges/rfuehricht-sanitizegp/health.svg)

```
[![Health](https://phpackages.com/badges/rfuehricht-sanitizegp/health.svg)](https://phpackages.com/packages/rfuehricht-sanitizegp)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
