Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use single quotes around 'maybe' atom for compatibility with OTP 27 #262

Merged
merged 6 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,34 @@ jobs:
os:
- ubuntu-latest
otp:
- "26.0.2.0"
- "25.3.2.3"
- "24.3.4.13"
- "23.3.4.18"
- "22.3.4.26"
- "21.3.8.24"
- "20.3.8.26"
- "19.3.6.13"
- "18.3.4.11"
- "27"
- "26"
- "25"
- "24"
- "23"
- "22"
- "21"
- "20"
steps:
- uses: actions/checkout@v4
- run: make test
- run: make edoc
- run: REBAR=rebar make test
test-eol:
name: test ${{matrix.otp}} on ${{matrix.os}}
runs-on: ${{matrix.os}}
container:
image: erlang:${{matrix.otp}}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
otp:
- "19"
- "18"
steps:
# The old containers can't run checkout@v4
- uses: actions/checkout@v3
- run: make test
- run: make edoc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Publish to Hex.pm
uses: erlangpack/github-action@v3
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Version 3.2.2 released XXXX-XX-XX
Version 3.2.2 released 2024-03-21

* Use single quotes around 'maybe' atom for compatibility with OTP 27
https://github.com/mochi/mochiweb/pull/262
* Update Erlang CI images
https://github.com/mochi/mochiweb/pull/261

Expand Down
5 changes: 3 additions & 2 deletions src/mochijson2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,9 @@ decode_map_test() ->
?assertEqual(M, decode(Json, [{format, map}])).

encode_map_test() ->
M = <<"{\"a\":1,\"b\":{\"c\":2}}">>,
?assertEqual(M, iolist_to_binary(encode(#{a => 1, b => #{ c => 2}}))).
?assertEqual(<<"{\"a\":1}">>, iolist_to_binary(encode(#{a => 1}))),
M = #{<<"a">> => 1, <<"b">> => #{<<"c">> => 2}},
?assertEqual(M, decode(iolist_to_binary(encode(#{a => 1, b => #{ c => 2}})), [{format, map}])).

encode_empty_map_test() ->
?assertEqual(<<"{}">>, encode(#{})).
Expand Down
2 changes: 1 addition & 1 deletion src/mochiweb.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% This is generated from src/mochiweb.app.src
{application, mochiweb,
[{description, "MochiMedia Web Server"},
{vsn, "3.2.1"},
{vsn, "3.2.2"},
{modules, []},
{registered, []},
{env, []},
Expand Down
12 changes: 6 additions & 6 deletions src/mochiweb_multipart.erl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ feed_mp(body,
C1 = Callback({body, Data}),
feed_mp(headers,
State#mp{callback = C1(body_end), buffer = Rest});
{maybe, Start} ->
{'maybe', Start} ->
<<Data:Start/binary, Rest/binary>> = Buffer,
feed_mp(body,
read_more(State#mp{callback = Callback({body, Data}),
Expand Down Expand Up @@ -328,15 +328,15 @@ find_boundary(Prefix, Data) ->
{end_boundary, Skip, size(Prefix) + 4};
_ when size(Data) < PrefixSkip + 4 ->
%% Underflow
{maybe, Skip};
{'maybe', Skip};
_ ->
%% False positive
not_found
end;
{partial, Skip, Length}
when Skip + Length =:= size(Data) ->
%% Underflow
{maybe, Skip};
{'maybe', Skip};
_ -> not_found
end.

Expand Down Expand Up @@ -695,8 +695,8 @@ find_boundary_test() ->
{end_boundary, 1, 9} = find_boundary(B,
<<"!\r\n--X--\r\nRest">>),
not_found = find_boundary(B, <<"--X\r\nRest">>),
{maybe, 0} = find_boundary(B, <<"\r\n--X\r">>),
{maybe, 1} = find_boundary(B, <<"!\r\n--X\r">>),
{'maybe', 0} = find_boundary(B, <<"\r\n--X\r">>),
{'maybe', 1} = find_boundary(B, <<"!\r\n--X\r">>),
P = <<"\r\n-----------------------------160374543510"
"82272548568224146">>,
B0 = <<55, 212, 131, 77, 206, 23, 216, 198, 35, 87, 252,
Expand All @@ -705,7 +705,7 @@ find_boundary_test() ->
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 49, 54, 48, 51,
55, 52, 53, 52, 51, 53, 49>>,
{maybe, 30} = find_boundary(P, B0),
{'maybe', 30} = find_boundary(P, B0),
not_found = find_boundary(B, <<"\r\n--XJOPKE">>),
ok.

Expand Down
26 changes: 13 additions & 13 deletions src/mochiweb_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -877,32 +877,32 @@ safe_relative_path_test() ->

parse_qvalues_test() ->
[] = parse_qvalues(""),
[{"identity", 0.0}] = parse_qvalues("identity;q=0"),
[{"identity", 0.0}] = parse_qvalues("identity ;q=0"),
[{"identity", 0.0}] = parse_qvalues(" identity; q =0 "),
[{"identity", 0.0}] = parse_qvalues("identity ; q = 0"),
[{"identity", 0.0}] = parse_qvalues("identity ; q= 0.0"),
[{"gzip", 1.0}, {"deflate", 1.0}, {"identity", 0.0}] = parse_qvalues(
[{"identity", +0.0}] = parse_qvalues("identity;q=0"),
[{"identity", +0.0}] = parse_qvalues("identity ;q=0"),
[{"identity", +0.0}] = parse_qvalues(" identity; q =0 "),
[{"identity", +0.0}] = parse_qvalues("identity ; q = 0"),
[{"identity", +0.0}] = parse_qvalues("identity ; q= 0.0"),
[{"gzip", 1.0}, {"deflate", 1.0}, {"identity", +0.0}] = parse_qvalues(
"gzip,deflate,identity;q=0.0"
),
[{"deflate", 1.0}, {"gzip", 1.0}, {"identity", 0.0}] = parse_qvalues(
[{"deflate", 1.0}, {"gzip", 1.0}, {"identity", +0.0}] = parse_qvalues(
"deflate,gzip,identity;q=0.0"
),
[{"gzip", 1.0}, {"deflate", 1.0}, {"gzip", 1.0}, {"identity", 0.0}] =
[{"gzip", 1.0}, {"deflate", 1.0}, {"gzip", 1.0}, {"identity", +0.0}] =
parse_qvalues("gzip,deflate,gzip,identity;q=0"),
[{"gzip", 1.0}, {"deflate", 1.0}, {"identity", 0.0}] = parse_qvalues(
[{"gzip", 1.0}, {"deflate", 1.0}, {"identity", +0.0}] = parse_qvalues(
"gzip, deflate , identity; q=0.0"
),
[{"gzip", 1.0}, {"deflate", 1.0}, {"identity", 0.0}] = parse_qvalues(
[{"gzip", 1.0}, {"deflate", 1.0}, {"identity", +0.0}] = parse_qvalues(
"gzip; q=1, deflate;q=1.0, identity;q=0.0"
),
[{"gzip", 0.5}, {"deflate", 1.0}, {"identity", 0.0}] = parse_qvalues(
[{"gzip", 0.5}, {"deflate", 1.0}, {"identity", +0.0}] = parse_qvalues(
"gzip; q=0.5, deflate;q=1.0, identity;q=0"
),
[{"gzip", 0.5}, {"deflate", 1.0}, {"identity", 0.0}] = parse_qvalues(
[{"gzip", 0.5}, {"deflate", 1.0}, {"identity", +0.0}] = parse_qvalues(
"gzip; q=0.5, deflate , identity;q=0.0"
),
[{"gzip", 0.5}, {"deflate", 0.8}, {"identity", 0.0}] = parse_qvalues(
[{"gzip", 0.5}, {"deflate", 0.8}, {"identity", +0.0}] = parse_qvalues(
"gzip; q=0.5, deflate;q=0.8, identity;q=0.0"
),
[{"gzip", 0.5}, {"deflate", 1.0}, {"identity", 1.0}] = parse_qvalues(
Expand Down
Loading