Skip to content

Regex patterns containing backticks generate invalid Go #612

Description

@piotrekwitkowski

Regex patterns are emitted as raw Go string literals. A pattern containing a backtick therefore produces invalid generated Go source.

For example, this schema pattern includes the permitted HTTP token characters:

pattern: "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"

The generated raw string is terminated by the embedded backtick, and the generated package does not compile.

#378 and #380 address related quoting problems but do not cover embedded backticks.

Expected behavior:

  • Generated Go compiles when a regex pattern contains a backtick.
  • The regex received at runtime is identical to the pattern in the schema.
  • Patterns containing backslashes, quotes, Unicode, or control characters are represented without changing their value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions