nickva commented on code in PR #4828:
URL: https://github.com/apache/couchdb/pull/4828#discussion_r1380652572


##########
src/mango/src/mango_idx_view.erl:
##########
@@ -417,7 +417,7 @@ range(_, _, LCmp, Low, HCmp, High) ->
 % beginsWith requires both a high and low bound
 range({[{<<"$beginsWith">>, Arg}]}, LCmp, Low, HCmp, High) ->
     {LCmp0, Low0, HCmp0, High0} = range({[{<<"$gte">>, Arg}]}, LCmp, Low, 
HCmp, High),
-    range({[{<<"$lte">>, <<Arg/binary, 16#10FFFF>>}]}, LCmp0, Low0, HCmp0, 
High0);
+    range({[{<<"$lte">>, <<Arg/binary, 16#10FFFF/utf8>>}]}, LCmp0, Low0, 
HCmp0, High0);

Review Comment:
   > "Erlang itself supports U+10FFFF and it is numerically greater than 
U+FFFF" -- while I accept that U+FFFF might be the Unicode-official marker, 
Erlang's support for a higher range worries me a bit.
   
   Perhaps confusingly unicode collation rules don't sort by code point values. 
Higher code-points may sort lower. Besides just `U+10FFFF` and `U+FFFF` there 
are other such example:
   
   ```erlang
   mango_json:cmp(<<16#1D175/utf8>>, <<16#41/utf8>>).
   -1
   ```
   
   Now, there may not be any other characters higher than U+10FFFF and lower 
than U+FFFF, so either one is probably ok in practice, but it's a bit neater if 
we can use the canonical max sorting character. Jiffy / erlang / 
couch_util:validate_utf8/1 should pass through both of those characters, so 
technically users could insert keys with those crazy values in them:
   
   ```erlang
   <<16#FFFF/utf8>> = jiffy:decode(<<"\"\\uFFFF\"">>).
   ```



-- 
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: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to