dominikmifkovic/detoxss/1.0.0

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/dominikmifkovic/detoxss is gone (deleted or private); Software Heritage has not archived the repo; no fork with the same repo name found; no cached copy. Use another version.

Details

DetoXSS.Core

Shared types and helpers used by the DetoXSS package.

This module defines lightweight wrappers for raw, validated, and sanitized content. The wrappers make the intended state of a value visible in type signatures.

The module also provides convenience aliases and helpers for whitelist state management.

type SafeContent state

A string wrapped with a phantom state.

The state parameter is used to distinguish raw, validated, and sanitized values at the type level.

Sanitized HTML-like content.

This alias is used for values that are intended to be safe to pass through the DetoXSS API after sanitization.

Validated input value.

This alias is used for values that passed validation rules, for example form input validation.

type alias RawInput =

Raw input value.

This alias is used for values that have not yet been validated or sanitized.

Phantom marker for sanitized content.

Values marked with this state are intended to represent content that has already gone through a sanitization step.

Phantom marker for validated content.

Values marked with this state are intended to represent content that has passed a validation step.

type Raw

Phantom marker for raw content.

Raw content should be treated as untrusted until it is validated, sanitized, or otherwise processed according to its output context.

fromRaw : String -> RawInput

Wrap a string as raw input.

This function does not validate or sanitize the value. It only marks the value as raw at the type level.

fromValidated : String -> ValidatedInput

Wrap a string as validated input.

This function does not perform validation by itself. It should be used only after the caller has already validated the value.

fromSanitized : String -> SafeHtml

Wrap a string as sanitized content.

This function does not sanitize the value by itself. It should be used only after the caller has already sanitized the value.

For actual sanitization, use functions from DetoXSS.Sanitize.

getContent : SafeContent state -> String

Extract the underlying string from a wrapped value.

type alias WhitelistState =
State

Alias for the whitelist runtime state.

defaultWhitelist : Whitelist

Default whitelist configuration.

initWhitelist : WhitelistState

Initial whitelist state.

The default whitelist configuration is loaded, but whitelist mode is disabled.

enableWhitelist : WhitelistState -> WhitelistState

Enable whitelist mode.

disableWhitelist : WhitelistState -> WhitelistState

Disable whitelist mode.

setWhitelist : Whitelist -> WhitelistState -> WhitelistState

Replace the whitelist configuration.

isWhitelistEnabled : WhitelistState -> Bool

Check whether whitelist mode is enabled.

isTagAllowed : WhitelistState -> String -> Bool

Check whether a tag is allowed by the whitelist state.

isAttrAllowed : WhitelistState -> String -> Bool

Check whether an attribute is allowed by the whitelist state.