Skip to main content

Strategy

Enum Strategy 

Source
#[non_exhaustive]
pub enum Strategy {
Show 35 variants UrlEncode, UrlEncodeLower, DoubleUrlEncode, TripleUrlEncode, UnicodeEncode, IisUnicodeEncode, JsonEncode, HtmlEntityEncode, HtmlEntityDecimalEncode, CaseAlternation, RandomCase, WhitespaceInsertion, SqlCommentInsertion, MysqlVersionedComment, NullByte, OverlongUtf8, OverlongUtf8More, ChunkedSplit, ParameterPollution, Base64Encode, Base64UrlEncode, HexEncode, Utf7Encode, GzipEncode, DeflateEncode, SpaceToComment, SpaceToDash, SpaceToHash, SpaceToPlus, SpaceToRandomBlank, PercentagePrefix, BetweenObfuscation, UnmagicQuotes, FullwidthEncode, HomoglyphEncode,
}
Expand description

Available encoding strategies.

§Context hints

Many strategies are only semantically correct in specific parser contexts. Use Strategy::contexts to query the applicable contexts for a strategy.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

UrlEncode

Standard URL encoding (%XX) — preserves unreserved chars per RFC 3986. Safe for: query strings, paths, form data.

§

UrlEncodeLower

Lowercase hex URL encoding (%xx) — same semantics as UrlEncode. Safe for: query strings, paths, form data.

§

DoubleUrlEncode

Double URL encoding (%25XX) — bypasses WAFs that decode once. Safe for: query strings, paths, form data.

§

TripleUrlEncode

Triple URL encoding (%2525XX) — bypasses WAFs that decode twice. Safe for: query strings, paths, form data.

§

UnicodeEncode

Unicode escape (\uXXXX) — ONLY safe when target parses JSON/JavaScript. Unsafe for: raw HTTP parameters, headers, most server frameworks.

§

IisUnicodeEncode

IIS/ASP percent Unicode (%uXXXX) — ONLY safe on IIS/ASP classic parsers. Unsafe for: modern servers (nginx, Apache, Node.js, etc.).

§

JsonEncode

JSON string encoding with Unicode escapes — ONLY safe in JSON contexts. Unsafe for: raw HTTP parameters.

§

HtmlEntityEncode

HTML entity encoding (&#xXX;) — ONLY safe in HTML contexts. Unsafe for: raw HTTP parameters, JSON bodies.

§

HtmlEntityDecimalEncode

HTML decimal entity encoding (<) — ONLY safe in HTML contexts. Unsafe for: raw HTTP parameters, JSON bodies.

§

CaseAlternation

Alternating case (SeLeCt) — bypasses case-sensitive keyword filters. Safe for: any text context where case is preserved.

§

RandomCase

Random alternating case — non-deterministic variant of CaseAlternation. Safe for: any text context where case is preserved.

§

WhitespaceInsertion

Tab insertion BETWEEN tokens — preserves keyword integrity. Safe for: SQL contexts where whitespace separates tokens.

§

SqlCommentInsertion

SQL comment insertion BETWEEN tokens — preserves keyword integrity. Safe for: SQL contexts where comments are treated as whitespace.

§

MysqlVersionedComment

MySQL versioned comment (/*!50000SELECT*/) — executed by MySQL, ignored by WAFs. Safe for: MySQL backends.

§

NullByte

Null byte injection (%00) — ONLY semantically correct for C-style string parsers. Context: php, some CGI implementations.

§

OverlongUtf8

Overlong UTF-8 encoding (2-byte) — ONLY works against legacy WAFs that normalize. Context: iis-6, very old frontends.

§

OverlongUtf8More

Extended overlong UTF-8 encoding (3-byte) — broader coverage than OverlongUtf8. Context: iis-6, very old frontends.

§

ChunkedSplit

Chunked transfer-encoding split — ONLY valid with Transfer-Encoding: chunked. Context: http-request-body.

§

ParameterPollution

HTTP parameter pollution — duplicate parameter with benign first value. Safe for: query strings, form data.

§

Base64Encode

Base64 encoding (standard alphabet). Safe for: headers, bodies, query strings (may need URL encoding after).

§

Base64UrlEncode

Base64 URL-safe encoding (-_ no padding). Safe for: URL contexts where +/ would be mangled.

§

HexEncode

Hex encoding. Safe for: any byte context.

§

Utf7Encode

UTF-7 encoding per RFC 2152. Context: legacy IIS/.NET parsers that decode UTF-7.

§

GzipEncode

Gzip compression — ONLY valid with Content-Encoding: gzip. Context: http-request-body.

§

DeflateEncode

Deflate compression — ONLY valid with Content-Encoding: deflate. Context: http-request-body.

§

SpaceToComment

Replace spaces with SQL comments (/**/). Safe for: SQL contexts.

§

SpaceToDash

Replace spaces with dash comments (--). Safe for: SQL contexts.

§

SpaceToHash

Replace spaces with hash comments (#). Safe for: MySQL contexts.

§

SpaceToPlus

Replace spaces with plus signs (+). Safe for: URL-encoded form data.

§

SpaceToRandomBlank

Replace spaces with random blank characters. Safe for: SQL contexts.

§

PercentagePrefix

Prefix each character with % — lightweight bypass. Safe for: contexts that strip % before parsing.

§

BetweenObfuscation

Between obfuscation (=BETWEEN # AND #). Safe for: SQL contexts.

§

UnmagicQuotes

Unmagic quotes (%bf%27) — multi-byte charset quote escape. Context: PHP with GBK/Big5/Shift-JIS connections.

§

FullwidthEncode

Fullwidth Unicode (SELECTuntouched) — bypasses ASCII keyword regex. Context: backends that perform NFKC normalization (Java, .NET, Python 3, PostgreSQL).

§

HomoglyphEncode

Homoglyph substitution — visually identical Unicode chars for ', ", <, >, =. Context: byte-level WAFs with Unicode-tolerant backends.

Implementations§

Source§

impl Strategy

Source

pub const fn as_str(&self) -> &'static str

Returns the string identifier for this encoding strategy.

Source

pub const fn contexts(&self) -> &'static [&'static str]

Returns the parser contexts where this strategy is semantically safe.

An empty slice means the strategy is generally applicable. Callers should gate strategy application by matching these contexts against the target type (e.g., json, html, sql, php, iis-6).

Trait Implementations§

Source§

impl Clone for Strategy

Source§

fn clone(&self) -> Strategy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Strategy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Strategy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Strategy

Source§

fn eq(&self, other: &Strategy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Strategy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Strategy

Source§

impl Eq for Strategy

Source§

impl StructuralPartialEq for Strategy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,