Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#constants) \| [Ctors](https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#pubctors) \| [Methods](https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#inhmethods)

# UrlQuerySanitizer.IllegalCharacterValueSanitizer

*** ** * ** ***


`
public
static


class
UrlQuerySanitizer.IllegalCharacterValueSanitizer
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.UrlQuerySanitizer.IllegalCharacterValueSanitizer |

<br />

*** ** * ** ***

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

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#IllegalCharacterValueSanitizer(int)(int flags) ` Construct a sanitizer. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer#sanitize(java.lang.String)(https://developer.android.com/reference/java/lang/String value) ` Sanitize a value. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer ` |---|---| | ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer#sanitize(java.lang.String)(https://developer.android.com/reference/java/lang/String value) ` Sanitize an unencoded value. | ||

## Constants

### ALL_BUT_NUL_AND_ANGLE_BRACKETS_LEGAL

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

```
public static final int ALL_BUT_NUL_AND_ANGLE_BRACKETS_LEGAL
```

<br />

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

<br />

<br />

Constant Value:

1439
(0x0000059f)


### ALL_BUT_NUL_LEGAL

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

```
public static final int ALL_BUT_NUL_LEGAL
```

<br />

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

<br />

<br />

Constant Value:

1535
(0x000005ff)


### ALL_BUT_WHITESPACE_LEGAL

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

```
public static final int ALL_BUT_WHITESPACE_LEGAL
```

<br />

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

<br />

<br />

Constant Value:

1532
(0x000005fc)


### ALL_ILLEGAL

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

```
public static final int ALL_ILLEGAL
```

<br />

- Deny all special characters.
- Deny script URLs.

<br />

<br />

Constant Value:

0
(0x00000000)


### ALL_OK

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

```
public static final int ALL_OK
```

Mask with all fields set to OK

<br />

Constant Value:

2047
(0x000007ff)


### ALL_WHITESPACE_OK

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

```
public static final int ALL_WHITESPACE_OK
```

Mask with both regular space and other whitespace OK

<br />

Constant Value:

3
(0x00000003)


### AMP_AND_SPACE_LEGAL

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

```
public static final int AMP_AND_SPACE_LEGAL
```

<br />

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

<br />

<br />

Constant Value:

129
(0x00000081)


### AMP_LEGAL

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

```
public static final int AMP_LEGAL
```

<br />

- Allow ampersand.
- Deny script URLs.

<br />

<br />

Constant Value:

128
(0x00000080)


### AMP_OK

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

```
public static final int AMP_OK
```

Allow ampersand characters ('\&')

<br />

Constant Value:

128
(0x00000080)


### DQUOTE_OK

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

```
public static final int DQUOTE_OK
```

Allow double quote characters. ('"')

<br />

Constant Value:

8
(0x00000008)


### GT_OK

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

```
public static final int GT_OK
```

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

<br />

Constant Value:

64
(0x00000040)


### LT_OK

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

```
public static final int LT_OK
```

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

<br />

Constant Value:

32
(0x00000020)


### NON_7_BIT_ASCII_OK

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

```
public static final int NON_7_BIT_ASCII_OK
```

Allow characters with character codes 128 to 255.

<br />

Constant Value:

4
(0x00000004)


### NUL_OK

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

```
public static final int NUL_OK
```

Allow nul characters ('\\0')

<br />

Constant Value:

512
(0x00000200)


### OTHER_WHITESPACE_OK

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

```
public static final int OTHER_WHITESPACE_OK
```

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

<br />

Constant Value:

2
(0x00000002)


### PCT_OK

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

```
public static final int PCT_OK
```

Allow percent-sign characters ('%')

<br />

Constant Value:

256
(0x00000100)


### SCRIPT_URL_OK

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

```
public static final int SCRIPT_URL_OK
```

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

<br />

Constant Value:

1024
(0x00000400)


### SPACE_LEGAL

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

```
public static final int SPACE_LEGAL
```

<br />

- Allow space.
- Deny script URLs.

<br />

<br />

Constant Value:

1
(0x00000001)


### SPACE_OK

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

```
public static final int SPACE_OK
```

Allow space (' ') characters.

<br />

Constant Value:

1
(0x00000001)


### SQUOTE_OK

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

```
public static final int SQUOTE_OK
```

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

<br />

Constant Value:

16
(0x00000010)


### URL_AND_SPACE_LEGAL

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

```
public static final int URL_AND_SPACE_LEGAL
```

<br />

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

<br />

<br />

Constant Value:

405
(0x00000195)


### URL_LEGAL

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

```
public static final int URL_LEGAL
```

<br />

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

<br />

<br />

Constant Value:

404
(0x00000194)


## Public constructors

### IllegalCharacterValueSanitizer

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

```
public IllegalCharacterValueSanitizer (int flags)
```

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

<br />

| Parameters ||
|---|---|
| `flags` | `int`: some combination of the XXX_OK flags. <br /> |

## Public methods

### sanitize

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

```
public String sanitize (String value)
```

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 />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the sanitized value <br /> |