This is an automated email from the ASF dual-hosted git repository. jan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5c93cb795d0960b8e5e88dd2c43ac77c87b56acb Author: Robert Newson <[email protected]> AuthorDate: Tue May 8 19:44:51 2018 +0100 Use couch_util:trim for greater erlang compatibility --- src/chttpd/src/chttpd_misc.erl | 2 +- src/couch/src/couch_httpd_misc_handlers.erl | 2 +- src/couch/src/couch_util.erl | 37 +++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl index 7be8a49..95345d4 100644 --- a/src/chttpd/src/chttpd_misc.erl +++ b/src/chttpd/src/chttpd_misc.erl @@ -293,7 +293,7 @@ handle_node_req(#httpd{path_parts=[_, _Node, <<"_config">>, _Section]}=Req) -> % "value" handle_node_req(#httpd{method='PUT', path_parts=[_, Node, <<"_config">>, Section, Key]}=Req) -> couch_util:check_config_blacklist(Section), - Value = string:trim(chttpd:json_body(Req)), + Value = couch_util:trim(chttpd:json_body(Req)), Persist = chttpd:header_value(Req, "X-Couch-Persist") /= "false", OldValue = call_node(Node, config, get, [Section, Key, ""]), case call_node(Node, config, set, [Section, Key, ?b2l(Value), Persist]) of diff --git a/src/couch/src/couch_httpd_misc_handlers.erl b/src/couch/src/couch_httpd_misc_handlers.erl index 258f1b2..0c70bcb 100644 --- a/src/couch/src/couch_httpd_misc_handlers.erl +++ b/src/couch/src/couch_httpd_misc_handlers.erl @@ -262,7 +262,7 @@ handle_approved_config_req(#httpd{method='PUT', path_parts=[_, Section, Key]}=Re <<"admins">> -> couch_passwords:hash_admin_password(RawValue); _ -> - string:trim(RawValue) + couch_util:trim(RawValue) end end, OldValue = config:get(Section, Key, ""), diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl index af1c0ef..72ee73f 100644 --- a/src/couch/src/couch_util.erl +++ b/src/couch/src/couch_util.erl @@ -302,11 +302,38 @@ separate_cmd_args(" " ++ Rest, CmdAcc) -> separate_cmd_args([Char|Rest], CmdAcc) -> separate_cmd_args(Rest, [Char | CmdAcc]). -% Is a character whitespace? -is_whitespace($\s) -> true; -is_whitespace($\t) -> true; -is_whitespace($\n) -> true; -is_whitespace($\r) -> true; +% Is a character whitespace (from https://en.wikipedia.org/wiki/Whitespace_character#Unicode)? +is_whitespace(9) -> true; +is_whitespace(10) -> true; +is_whitespace(11) -> true; +is_whitespace(12) -> true; +is_whitespace(13) -> true; +is_whitespace(32) -> true; +is_whitespace(133) -> true; +is_whitespace(160) -> true; +is_whitespace(5760) -> true; +is_whitespace(8192) -> true; +is_whitespace(8193) -> true; +is_whitespace(8194) -> true; +is_whitespace(8195) -> true; +is_whitespace(8196) -> true; +is_whitespace(8197) -> true; +is_whitespace(8198) -> true; +is_whitespace(8199) -> true; +is_whitespace(8200) -> true; +is_whitespace(8201) -> true; +is_whitespace(8202) -> true; +is_whitespace(8232) -> true; +is_whitespace(8233) -> true; +is_whitespace(8239) -> true; +is_whitespace(8287) -> true; +is_whitespace(12288) -> true; +is_whitespace(6158) -> true; +is_whitespace(8203) -> true; +is_whitespace(8204) -> true; +is_whitespace(8205) -> true; +is_whitespace(8288) -> true; +is_whitespace(65279) -> true; is_whitespace(_Else) -> false.
