[ 
https://issues.apache.org/jira/browse/THRIFT-6012?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmytro Shteflyuk resolved THRIFT-6012.
--------------------------------------
    Fix Version/s: 0.24.0
       Resolution: Fixed

> Fix inverted regexp.MatchString arguments and precompile patterns in Go 
> validator
> ---------------------------------------------------------------------------------
>
>                 Key: THRIFT-6012
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6012
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>            Reporter: Roman Dmytrenko
>            Priority: Major
>             Fix For: 0.24.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The Go struct validator generator has two bugs in vt.pattern handling:
> 1. Incorrect argument order - regexp.MatchString(target, pattern) swaps the 
> parameters. The correct signature is regexp.MatchString(pattern, s), so the 
> pattern must come first. This causes all vt.pattern validations to behave 
> incorrectly (matching the pattern against the pattern string rather than 
> against the field value).
> 2. Repeated regex compilation - regexp.MatchString compiles the pattern on 
> every call. For structs validated frequently (e.g., in a hot loop), this is 
> wasteful.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to