Skip to content

Escape single quotes in validation messages #898

@sdurrenmatt

Description

@sdurrenmatt

Validation messages that contain single quotes are not properly escaped, resulting in missing single quotes and uninterpreted format elements. For example, the French "pattern" validation message {0} ne correspond pas à l'expression régulière {1} with args $.foo and (foo)+ will result in $.foo ne correspond pas à lexpression régulière {1}.

See MessageFormat

Within a String, a pair of single quotes can be used to quote any arbitrary characters except single quotes. For example, pattern string "'{0}'" represents string "{0}", not a FormatElement. A single quote itself must be represented by doubled single quotes '' throughout a String. For example, pattern string "'{''}'" is interpreted as a sequence of '{ (start of quoting and a left curly brace), '' (a single quote), and }' (a right curly brace and end of quoting), not '{' and '}' (quoted left and right curly braces): representing string "{'}", not "{}".

Any unmatched quote is treated as closed at the end of the given pattern. For example, pattern string "'{0}" is treated as pattern "'{0}'".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions