diff options
author | Robert Newson <rnewson@apache.org> | 2011-05-06 15:39:46 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2011-05-06 15:39:46 +0000 |
commit | fc90ac341c154eac58780d8040263cb3df62512d (patch) | |
tree | 24a59144e979d5aebac62f02299207bb9f2d868f /src/couchdb | |
parent | fb1057865732d81456ab1ca570c410835dcd0929 (diff) |
COUCHDB-760 - allow utf-8 in attachment names (patch by davisp/benoitc)
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1100254 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 0b8f891b..0dbebb6e 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -1276,34 +1276,8 @@ validate_attachment_name(Name) when is_list(Name) -> validate_attachment_name(<<"_",_/binary>>) -> throw({bad_request, <<"Attachment name can't start with '_'">>}); validate_attachment_name(Name) -> - case is_valid_utf8(Name) of + case couch_util:validate_utf8(Name) of true -> Name; false -> throw({bad_request, <<"Attachment name is not UTF-8 encoded">>}) end. -%% borrowed from mochijson2:json_bin_is_safe() -is_valid_utf8(<<>>) -> - true; -is_valid_utf8(<<C, Rest/binary>>) -> - case C of - $\" -> - false; - $\\ -> - false; - $\b -> - false; - $\f -> - false; - $\n -> - false; - $\r -> - false; - $\t -> - false; - C when C >= 0, C < $\s; C >= 16#7f, C =< 16#10FFFF -> - false; - C when C < 16#7f -> - is_valid_utf8(Rest); - _ -> - false - end. |