Skip to content

Commit

Permalink
Do not escape regular expressions again (getkin#429)
Browse files Browse the repository at this point in the history
The string representing the regular expression is already escaped, using '%q' escapes it again, resulting in the wrong regex being displayed.
  • Loading branch information
jmml97 committed Oct 8, 2021
1 parent 5a162f6 commit 5c2918f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openapi3/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ func (schema *Schema) visitJSONString(settings *schemaValidationSettings, value
Value: value,
Schema: schema,
SchemaField: "pattern",
Reason: fmt.Sprintf("string doesn't match the regular expression %q", schema.Pattern),
Reason: fmt.Sprintf("string doesn't match the regular expression \"%s\"", schema.Pattern),
}
if !settings.multiError {
return err
Expand All @@ -1182,7 +1182,7 @@ func (schema *Schema) visitJSONString(settings *schemaValidationSettings, value
switch {
case f.regexp != nil && f.callback == nil:
if cp := f.regexp; !cp.MatchString(value) {
formatErr = fmt.Sprintf("string doesn't match the format %q (regular expression %q)", format, cp.String())
formatErr = fmt.Sprintf("string doesn't match the format %q (regular expression \"%s\")", format, cp.String())
}
case f.regexp == nil && f.callback != nil:
if err := f.callback(value); err != nil {
Expand Down

0 comments on commit 5c2918f

Please sign in to comment.