You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/04/03 13:56:33 UTC
[GitHub] [couchdb] Swaser opened a new issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Swaser opened a new issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756
When using the .toLowerCase() (or the .toLocalLowerCase()) function on strings containing Umlauts, the design document view will not produce any results.
## Description
See above.
## Steps to Reproduce
1. Create a database and add any document to it.
1. Creata a design document with a view and use the following code
```
function (doc) {
emit('Ä'.toLowerCase(),1);
}
```
## Expected Behaviour
A view will be created with at least one entry (as many as there were documents) with `key: 'ä'` and `value: 1`.
## Your Environment
* CouchDB version used: 3.0.0 dockerized and pulled from dockerhub (couchdb:latest)
* Browser name and version: Firefox 74.0
* Operating system and version: docker on Xubuntu 19.10
## Additional Context
[TIP]: # ( Add any other context about the problem here. )
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] Swaser commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
Swaser commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608997091
I don't know exactly what you mean by saying there's an error by adding any string with an Umlaut, but this code here works:
```
function (doc) {
emit('Ä',1);
}
```
so it is really the Javascript function toLowerCase() that produces the invalid string.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] wohali commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
wohali commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-612659673
@florianb note #2779 which has some additional failed functions.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] florianb edited a comment on issue #2756:
String.toLowerCase() produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
florianb edited a comment on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608594814
I will try to dig deeper - since my error (`invalid_json`/`invalid_string`) is already appearing when adding any string with an Umlaut to the view's source, i could imagine the error happens before the code is parsed by SM.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] wohali commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
wohali commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608574861
@florianb I'm largely relaying here what @davisp said in developer chat, so I can't really comment further.
Going to remove the tag for now and put this back to `needs-triage`.
@jiangphcn are you able to investigate at all?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] florianb commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
florianb commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-613259030
Thank you very much @wohali!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] florianb commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
florianb commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608594814
I will try to dig deeper - since my error (`invalid_json`/`invalid_string`) is already appearing when adding any string with an Umlaut is added to the view's source, i could imagine the error happens before the code is parsed by SM.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] davisp commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
davisp commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608579686
I'm working off my 1.8.5 JS shell which is what we would have used for 2.3.1 so I'm not sure how it would have worked if we're thinking the newer SM was an issue.
Do you have something handy that you can do a quick `JSON.stringify("Ä".toLowerCase())` where it used to work so we can see if something is changing the behavior (i.e., maybe a locale setting or something)?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] Swaser commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
Swaser commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608997889
Tell me, if I can help.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] florianb commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
florianb commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608548929
Trying to test the example leads to the following error on my instance:
```
couchdb_1 | [info] 2020-04-03T16:48:09.950145Z nonode@nohost <0.5379.0> -------- Starting index update for db: shards/80000000-ffffffff/test.1585932129 idx: _design/test
couchdb_1 | [error] 2020-04-03T16:48:09.954051Z nonode@nohost emulator -------- Error in process <0.5387.0> with exit value:
couchdb_1 | {{nocatch,{invalid_json,{5,invalid_string}}},[{couch_util,json_decode,1,[{file,"src/couch_util.erl"},{line,505}]},{couch_mrview_updater,merge_results,3,[{file,"src/couch_mrview_updater.erl"},{line,245}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{couch_mrview_updater,merge_results,4,[{file,"src/couch_mrview_updater.erl"},{line,238}]},{couch_mrview_updater,accumulate_writes,3,[{file,"src/couch_mrview_updater.erl"},{line,215}]},{couch_mrview_updater,write_results,2,[{file,"src/couch_mrview_updater.erl"},{line,179}]}]}
```
This applies to an used Umlaut in **any** string-literal in the view. I am short on time, couldn't test it with different Unicode-Characters or functions.
I use Fauxton to update the view.
---
Tested on hub.docker.com provided `couchdb:latest` 3.0.0.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] florianb commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
florianb commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608997719
That's right - it crashes when adding `.toLowerCase()` - i am still trying to collect more information.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] florianb commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
florianb commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608574117
@wohali - that's interesting, the same worked with the docker repo of 2.3.1.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [couchdb] wohali commented on issue #2756: String.toLowerCase()
produces error on strings with Umlaut.
Posted by GitBox <gi...@apache.org>.
wohali commented on issue #2756: String.toLowerCase() produces error on strings with Umlaut.
URL: https://github.com/apache/couchdb/issues/2756#issuecomment-608573068
Hi there,
Unfortunately, this is a known problem with CouchDB + JavaScript + string mutation going way back. We need to document this better.
Inside of CouchDB, we only support 100% valid UTF-8 encoding. JavaScript, in this case, is producing an invalid UTF-8 encoding. You can see this here:
https://gist.github.com/davisp/78035ad6d3be799cbe8bd397e0d0be1f
It's unfortunate that JavaScript here is producing invalid UTF-8, but CouchDB is doing the "right thing" by rejecting it.
Comment from @davisp :
> AFAIK JavaScript is hoplessly broken with respect to Unicode because of how it defines strings as 16bit integers and doesn't care about multi-byte representations. This is JavaScript allowing string mutations that produce invalid UTF-8 when encoded as JSON. This has happened before with e.g. string reversal.
That JavaScript will happily produce invalid JSON/UTF-8 binaries is sadness, but there's not a lot we can do about this here.
So for now, I'm going to leave this open, but tag it as a `wontfix`. I realize this isn't the best approach, and I'm not happy about the result either.
If someone with knowledge of the code can suggest a fix or workaround, please feel free to comment. Dogpiling on this issue to complain won't help anyone (and will probably actively discourage anyone from trying to resolve it.)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services