# UrlQuerySanitizer.IllegalCharacterValueSanitizer

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# IllegalCharacterValueSanitizer

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer "View this page in Java")  

```
open class IllegalCharacterValueSanitizer : UrlQuerySanitizer.ValueSanitizer
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                               ||
| ↳ | [android.net.UrlQuerySanitizer.IllegalCharacterValueSanitizer](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#) |

Sanitize values based on which characters they contain. Illegal characters are replaced with either space or '_', depending upon whether space is a legal character or not.

## Summary

|                                                                                                                                                                                      Constants                                                                                                                                                                                       ||
|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ALL_BUT_NUL_AND_ANGLE_BRACKETS_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#ALL_BUT_NUL_AND_ANGLE_BRACKETS_LEGAL:kotlin.Int) <br /> - Allow all but. - Nul ('\\0') - Angle brackets ('\<', '\>') - Deny script URLs. <br /> |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ALL_BUT_NUL_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#ALL_BUT_NUL_LEGAL:kotlin.Int) <br /> - Allow all special characters except Nul. ('\\0'). - Allow script URLs. <br />                                               |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ALL_BUT_WHITESPACE_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#ALL_BUT_WHITESPACE_LEGAL:kotlin.Int) <br /> - Allow all special characters except for: - whitespace characters - Nul ('\\0') - Allow script URLs. <br />    |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ALL_ILLEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#ALL_ILLEGAL:kotlin.Int) <br /> - Deny all special characters. - Deny script URLs. <br />                                                                                 |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ALL_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#ALL_OK:kotlin.Int) Mask with all fields set to OK                                                                                                                             |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ALL_WHITESPACE_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#ALL_WHITESPACE_OK:kotlin.Int) Mask with both regular space and other whitespace OK                                                                                 |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [AMP_AND_SPACE_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#AMP_AND_SPACE_LEGAL:kotlin.Int) <br /> - Allow ampersand. - Allow space. - Deny script URLs. <br />                                                              |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [AMP_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#AMP_LEGAL:kotlin.Int) <br /> - Allow ampersand. - Deny script URLs. <br />                                                                                                 |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [AMP_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#AMP_OK:kotlin.Int) Allow ampersand characters ('\&')                                                                                                                          |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [DQUOTE_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#DQUOTE_OK:kotlin.Int) Allow double quote characters.                                                                                                                       |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [GT_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#GT_OK:kotlin.Int) Allow greater-than characters.                                                                                                                               |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [LT_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#LT_OK:kotlin.Int) Allow less-than characters.                                                                                                                                  |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [NON_7_BIT_ASCII_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#NON_7_BIT_ASCII_OK:kotlin.Int) Allow characters with character codes 128 to 255.                                                                                  |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [NUL_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#NUL_OK:kotlin.Int) Allow nul characters ('\\0')                                                                                                                               |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [OTHER_WHITESPACE_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#OTHER_WHITESPACE_OK:kotlin.Int) Allow whitespace characters other than space.                                                                                    |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [PCT_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#PCT_OK:kotlin.Int) Allow percent-sign characters ('%')                                                                                                                        |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SCRIPT_URL_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#SCRIPT_URL_OK:kotlin.Int) Allow text to start with a script URL such as "javascript:" or "vbscript:"                                                                   |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SPACE_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#SPACE_LEGAL:kotlin.Int) <br /> - Allow space. - Deny script URLs. <br />                                                                                                 |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SPACE_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#SPACE_OK:kotlin.Int) Allow space (' ') characters.                                                                                                                          |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SQUOTE_OK](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#SQUOTE_OK:kotlin.Int) Allow single quote characters.                                                                                                                       |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [URL_AND_SPACE_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#URL_AND_SPACE_LEGAL:kotlin.Int) <br /> - Allow characters used by encoded URLs. - Allow spaces. - Deny script URLs. <br />                                       |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [URL_LEGAL](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#URL_LEGAL:kotlin.Int) <br /> - Allow characters used by encoded URLs. - Deny script URLs. <br />                                                                           |

|                                                                                                                                             Public constructors                                                                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [IllegalCharacterValueSanitizer](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#IllegalCharacterValueSanitizer(kotlin.Int))`(`flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Construct a sanitizer. |

|                                                                                                                                                                      Public methods                                                                                                                                                                      ||
|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [sanitize](https://developer.android.com/reference/kotlin/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#sanitize(kotlin.String))`(`value:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Sanitize a value. |

## Constants

### ALL_BUT_NUL_AND_ANGLE_BRACKETS_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ALL_BUT_NUL_AND_ANGLE_BRACKETS_LEGAL: Int
```

<br />

- Allow all but.
  - Nul ('\\0')
  - Angle brackets ('\<', '\>')
- Deny script URLs.

<br />

    Value: 1439

### ALL_BUT_NUL_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ALL_BUT_NUL_LEGAL: Int
```

<br />

- Allow all special characters except Nul. ('\\0').
- Allow script URLs.

<br />

    Value: 1535

### ALL_BUT_WHITESPACE_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ALL_BUT_WHITESPACE_LEGAL: Int
```

<br />

- Allow all special characters except for:
  - whitespace characters
  - Nul ('\\0')
- Allow script URLs.

<br />

    Value: 1532

### ALL_ILLEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ALL_ILLEGAL: Int
```

<br />

- Deny all special characters.
- Deny script URLs.

<br />

    Value: 0

### ALL_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ALL_OK: Int
```

Mask with all fields set to OK  

    Value: 2047

### ALL_WHITESPACE_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ALL_WHITESPACE_OK: Int
```

Mask with both regular space and other whitespace OK  

    Value: 3

### AMP_AND_SPACE_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val AMP_AND_SPACE_LEGAL: Int
```

<br />

- Allow ampersand.
- Allow space.
- Deny script URLs.

<br />

    Value: 129

### AMP_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val AMP_LEGAL: Int
```

<br />

- Allow ampersand.
- Deny script URLs.

<br />

    Value: 128

### AMP_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val AMP_OK: Int
```

Allow ampersand characters ('\&')  

    Value: 128

### DQUOTE_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val DQUOTE_OK: Int
```

Allow double quote characters. ('"')  

    Value: 8

### GT_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val GT_OK: Int
```

Allow greater-than characters. ('\>')  

    Value: 64

### LT_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val LT_OK: Int
```

Allow less-than characters. ('\<')  

    Value: 32

### NON_7_BIT_ASCII_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val NON_7_BIT_ASCII_OK: Int
```

Allow characters with character codes 128 to 255.  

    Value: 4

### NUL_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val NUL_OK: Int
```

Allow nul characters ('\\0')  

    Value: 512

### OTHER_WHITESPACE_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val OTHER_WHITESPACE_OK: Int
```

Allow whitespace characters other than space. The other whitespace characters are '\\t' '\\f' '\\n' '\\r' and '\\0x000b' (vertical tab)  

    Value: 2

### PCT_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val PCT_OK: Int
```

Allow percent-sign characters ('%')  

    Value: 256

### SCRIPT_URL_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val SCRIPT_URL_OK: Int
```

Allow text to start with a script URL such as "javascript:" or "vbscript:"  

    Value: 1024

### SPACE_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val SPACE_LEGAL: Int
```

<br />

- Allow space.
- Deny script URLs.

<br />

    Value: 1

### SPACE_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val SPACE_OK: Int
```

Allow space (' ') characters.  

    Value: 1

### SQUOTE_OK

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val SQUOTE_OK: Int
```

Allow single quote characters. ('\\'')  

    Value: 16

### URL_AND_SPACE_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val URL_AND_SPACE_LEGAL: Int
```

<br />

- Allow characters used by encoded URLs.
- Allow spaces.
- Deny script URLs.

<br />

    Value: 405

### URL_LEGAL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val URL_LEGAL: Int
```

<br />

- Allow characters used by encoded URLs.
- Deny script URLs.

<br />

    Value: 404

## Public constructors

### IllegalCharacterValueSanitizer

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
IllegalCharacterValueSanitizer(flags: Int)
```

Construct a sanitizer. The parameters set the behavior of the sanitizer.

|                                                        Parameters                                                         ||
|---------|------------------------------------------------------------------------------------------------------------------|
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):some combination of the XXX_OK flags. |

## Public methods

### sanitize

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun sanitize(value: String!): String!
```

Sanitize a value.

1. If script URLs are not OK, they will be removed.
2. If neither spaces nor other white space is OK, then white space will be trimmed from the beginning and end of the URL. (Just the actual white space characters are trimmed, not other control codes.)
3. Illegal characters will be replaced with either ' ' or '_', depending on whether a space is itself a legal character.

<br />

|                                         Parameters                                          ||
|---------|------------------------------------------------------------------------------------|
| `value` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: |

|                                                 Return                                                 ||
|-----------------------------------------------------------------------------------|---------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | the sanitized value |