pgj commented on PR #4828:
URL: https://github.com/apache/couchdb/pull/4828#issuecomment-1790482735

   If you implement the pre-check that I suggested then it can be established 
for `mango_idx_view:range/5` that the input will always be a valid UTF-8 input 
hence no tests are needed.  The requirement for the test could be then pushed 
to the validation phase.
   
   When I experimented with this fix locally, I extended 
`mango_selector:norm_ops/1` as follows:
   
   ```diff
   diff --git a/src/mango/src/mango_selector.erl 
b/src/mango/src/mango_selector.erl
   index 93d3b10ca..24660e963 100644
   --- a/src/mango/src/mango_selector.erl
   +++ b/src/mango/src/mango_selector.erl
   @@ -136,7 +136,10 @@ norm_ops({[{<<"$text">>, Arg}]}) when
    norm_ops({[{<<"$text">>, Arg}]}) ->
        ?MANGO_ERROR({bad_arg, '$text', Arg});
    norm_ops({[{<<"$beginsWith">>, Arg}]} = Cond) when is_binary(Arg) ->
   -    Cond;
   +    case couch_util:validate_utf8(Arg) of
   +        true -> Cond;
   +        false -> ?MANGO_ERROR({bad_arg, '$beginsWith', Arg})
   +    end;
    % Not technically an operator but we pass it through here
    % so that this function accepts its own output. This exists
    % so that $text can have a field name value which simplifies
   ```
   
   With that, the existing definition of `match_beginswith_test/0` in the same 
module could be extended naturally.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to