You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2022/08/15 18:33:31 UTC

[couchdb-mochiweb] branch main updated (845803a -> 41a4314)

This is an automated email from the ASF dual-hosted git repository.

ronny pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-mochiweb.git


    from 845803a  Merge pull request #241 from mochi/rebar3
     new 0e6d5d1  Fix typo in atom
     new f2ec849  Remove leading and trailing whitespaces
     new a9abeae  v3.1.0
     new 41a4314  fix release date

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.md               |  7 +++++++
 src/mochiweb.app.src     |  2 +-
 src/mochiweb_headers.erl | 18 ++++++++++++++----
 3 files changed, 22 insertions(+), 5 deletions(-)


[couchdb-mochiweb] 03/04: v3.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ronny pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-mochiweb.git

commit a9abeae845cea620e949d43a60549f6ed3638171
Author: Bob Ippolito <bo...@redivi.com>
AuthorDate: Sat Aug 13 20:16:40 2022 -0600

    v3.1.0
---
 CHANGES.md               | 7 +++++++
 src/mochiweb.app.src     | 2 +-
 src/mochiweb_headers.erl | 9 ++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 16d14f7..e851ce3 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,10 @@
+Version 3.1.0 released 2022-08-21
+
+* Leading and trailing whitespace in header values are now trimmed
+  for better RFC 7230 compliance.
+  https://github.com/mochi/mochiweb/pull/247
+  https://github.com/mochi/mochiweb/pull/248
+
 Version 3.0.0 released 2022-05-09
 
 * rebar3 is now the preferred build tool (finally)
diff --git a/src/mochiweb.app.src b/src/mochiweb.app.src
index 6baf6bf..425e220 100644
--- a/src/mochiweb.app.src
+++ b/src/mochiweb.app.src
@@ -1,7 +1,7 @@
 %% This is generated from src/mochiweb.app.src
 {application, mochiweb,
  [{description, "MochiMedia Web Server"},
-  {vsn, "3.0.0"},
+  {vsn, "3.1.0"},
   {modules, []},
   {registered, []},
   {env, []},
diff --git a/src/mochiweb_headers.erl b/src/mochiweb_headers.erl
index d9bc3af..afb8a1f 100644
--- a/src/mochiweb_headers.erl
+++ b/src/mochiweb_headers.erl
@@ -216,7 +216,7 @@ tokenize_header_value(V) ->
     reversed_tokens(trim_and_reverse(V, false), [], []).
 
 trim_leading_and_trailing_ws(S) ->
-    re:replace(S, "^[ \\t]*|[ \\t]*$", "", [global, {return, list}]).
+    trim_and_reverse(trim_and_reverse(S, false), false).
 
 trim_and_reverse([S | Rest], Reversed) when S=:=$ ; S=:=$\n; S=:=$\t ->
     trim_and_reverse(Rest, Reversed);
@@ -367,6 +367,13 @@ set_cookie_test() ->
        to_list(H)),
     ok.
 
+whitespace_headers_test() ->
+    %% Check RFC 7230 whitespace compliance
+    H = ?MODULE:make([{"X-Auth-Roles", "      test, test2,test3,       test4,    test5     ,        test6     "}]),
+    ?assertEqual(
+       [{"X-Auth-Roles", "test, test2,test3,       test4,    test5     ,        test6"}],
+       to_list(H)).
+
 headers_test() ->
     H = ?MODULE:make([{hdr, foo}, {"Hdr", "bar"}, {'Hdr', 2}]),
     [{hdr, "foo, bar, 2"}] = ?MODULE:to_list(H),


[couchdb-mochiweb] 04/04: fix release date

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ronny pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-mochiweb.git

commit 41a43143ff221c37c3ac6ae932ddd5ad2278d769
Author: Bob Ippolito <bo...@redivi.com>
AuthorDate: Sat Aug 13 20:35:05 2022 -0600

    fix release date
---
 CHANGES.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index e851ce3..bb76d79 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-Version 3.1.0 released 2022-08-21
+Version 3.1.0 released 2022-08-13
 
 * Leading and trailing whitespace in header values are now trimmed
   for better RFC 7230 compliance.


[couchdb-mochiweb] 01/04: Fix typo in atom

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ronny pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-mochiweb.git

commit 0e6d5d15185e0d7a69e721d307671593130fa36b
Author: Ronny <ro...@apache.org>
AuthorDate: Thu Aug 11 10:07:15 2022 +0200

    Fix typo in atom
---
 src/mochiweb_headers.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mochiweb_headers.erl b/src/mochiweb_headers.erl
index 457758f..0276aee 100644
--- a/src/mochiweb_headers.erl
+++ b/src/mochiweb_headers.erl
@@ -242,7 +242,7 @@ reversed_tokens([C | Rest], Token, Acc) when C=:=$ ;C=:=$\n;C=:=$\t;C=:=$, ->
 reversed_tokens([C | Rest], Token, Acc) ->
     reversed_tokens(Rest, [C | Token], Acc);
 reversed_tokens(_, _, _) ->
-    undefeined.
+    undefined.
 
 extract_quoted_string([], _Acc) ->
     undefined;


[couchdb-mochiweb] 02/04: Remove leading and trailing whitespaces

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ronny pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-mochiweb.git

commit f2ec849d8c52284ce699f97ab3108322a58eaec5
Author: Ronny <ro...@apache.org>
AuthorDate: Thu Aug 11 15:47:29 2022 +0200

    Remove leading and trailing whitespaces
    
    from field-values to be RFC 7230 compliant.
---
 src/mochiweb_headers.erl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mochiweb_headers.erl b/src/mochiweb_headers.erl
index 0276aee..d9bc3af 100644
--- a/src/mochiweb_headers.erl
+++ b/src/mochiweb_headers.erl
@@ -174,7 +174,7 @@ lookup(K, T) ->
 %% @doc Insert the pair into the headers if it does not already exist.
 default(K, V, T) ->
     K1 = normalize(K),
-    V1 = any_to_list(V),
+    V1 = trim_leading_and_trailing_ws(any_to_list(V)),
     try gb_trees:insert(K1, {K, V1}, T)
     catch
         error:{key_exists, _} ->
@@ -185,7 +185,7 @@ default(K, V, T) ->
 %% @doc Insert the pair into the headers, replacing any pre-existing key.
 enter(K, V, T) ->
     K1 = normalize(K),
-    V1 = any_to_list(V),
+    V1 = trim_leading_and_trailing_ws(any_to_list(V)),
     gb_trees:enter(K1, {K, V1}, T).
 
 %% @spec insert(key(), value(), headers()) -> headers()
@@ -193,7 +193,7 @@ enter(K, V, T) ->
 %%      A merge is done with Value = V0 ++ ", " ++ V1.
 insert(K, V, T) ->
     K1 = normalize(K),
-    V1 = any_to_list(V),
+    V1 = trim_leading_and_trailing_ws(any_to_list(V)),
     try gb_trees:insert(K1, {K, V1}, T)
     catch
         error:{key_exists, _} ->
@@ -215,6 +215,9 @@ tokenize_header_value(undefined) ->
 tokenize_header_value(V) ->
     reversed_tokens(trim_and_reverse(V, false), [], []).
 
+trim_leading_and_trailing_ws(S) ->
+    re:replace(S, "^[ \\t]*|[ \\t]*$", "", [global, {return, list}]).
+
 trim_and_reverse([S | Rest], Reversed) when S=:=$ ; S=:=$\n; S=:=$\t ->
     trim_and_reverse(Rest, Reversed);
 trim_and_reverse(V, false) ->