Module: ActiveJob::Temporal::VisibilityQuery

Defined in:
lib/activejob/temporal/visibility_query.rb

Constant Summary collapse

SAFE_VALUE_PATTERN =
/\A[A-Za-z0-9_.:-]+\z/

Class Method Summary collapse

Class Method Details

.quote(value) ⇒ String

Quotes a value for use in a Temporal visibility list filter.

Escaping alone is not enough: Temporal's list filter grammar also treats backslashes as escapes, so a value containing one can break out of the quoted literal. Values are restricted to an allowlist instead.

Parameters:

  • value (#to_s)

    Value to embed in a list filter

Returns:

  • (String)

    Single-quoted literal

Raises:

  • (ArgumentError)

    if the value contains characters outside the allowlist



19
20
21
22
23
24
25
# File 'lib/activejob/temporal/visibility_query.rb', line 19

def quote(value)
  string_value = value.to_s
  return "'#{string_value}'" if string_value.match?(SAFE_VALUE_PATTERN)

  raise ArgumentError,
        "visibility query values may only contain letters, numbers, underscore, hyphen, period, and colon"
end