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

OTP 20 compatability #28

Open
wants to merge 3 commits into
base: develop-3.0-merge29
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
*.swp
*.beam
*.dump
_build/*
rebar.lock
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PREFIX:=../
DEST:=$(PREFIX)$(PROJECT)

REBAR=./rebar
REBAR=./rebar3

.PHONY: all edoc test clean build_plt dialyzer app

Expand Down
Binary file removed rebar
Binary file not shown.
Binary file added rebar3
Binary file not shown.
7 changes: 7 additions & 0 deletions src/mochitemp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ rngchars(0) ->
rngchars(N) ->
[rngchar() | rngchars(N - 1)].


-ifdef(crypto_compatibility).
rngchar() ->
rngchar(crypto:rand_uniform(0, tuple_size(?SAFE_CHARS))).
-else.
rngchar() ->
rngchar(rand:uniform(tuple_size(?SAFE_CHARS)) - 1).
-endif.


rngchar(C) ->
element(1 + C, ?SAFE_CHARS).
Expand Down
2 changes: 1 addition & 1 deletion src/mochiweb_html.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-module(mochiweb_html).
-export([tokens/1, parse/1, parse_tokens/1, to_tokens/1, escape/1,
escape_attr/1, to_html/1]).
-compile([export_all]).

-ifdef(TEST).
-export([destack/1, destack/2, is_singleton/1]).
-endif.
Expand Down
5 changes: 2 additions & 3 deletions src/mochiweb_multipart.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ parts_to_body([{Start, End, Body}], ContentType, Size) ->
{HeaderList, Body};
parts_to_body(BodyList, ContentType, Size) when is_list(BodyList) ->
parts_to_multipart_body(BodyList, ContentType, Size,
mochihex:to_hex(crypto:rand_bytes(8))).
mochihex:to_hex(crypto:strong_rand_bytes(8))).

%% @spec parts_to_multipart_body([bodypart()], ContentType::string(),
%% Size::integer(), Boundary::string()) ->
Expand Down Expand Up @@ -315,8 +315,7 @@ find_boundary(Prefix, Data) ->
-include_lib("eunit/include/eunit.hrl").

ssl_cert_opts() ->
EbinDir = filename:dirname(code:which(?MODULE)),
CertDir = filename:join([EbinDir, "..", "support", "test-materials"]),
CertDir = filename:join(["support", "test-materials"]),
CertFile = filename:join(CertDir, "test_ssl_cert.pem"),
KeyFile = filename:join(CertDir, "test_ssl_key.pem"),
[{certfile, CertFile}, {keyfile, KeyFile}].
Expand Down
2 changes: 1 addition & 1 deletion src/mochiweb_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ gen_hmac(ExpirationTime, Data, SessionKey, Key) ->
-else.
-spec encrypt_data(binary(), binary()) -> binary().
encrypt_data(Data, Key) ->
IV = crypto:rand_bytes(16),
IV = crypto:strong_rand_bytes(16),
Crypt = crypto:block_encrypt(aes_cfb128, Key, IV, Data),
<<IV/binary, Crypt/binary>>.

Expand Down
2 changes: 1 addition & 1 deletion src/mochiweb_websocket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-export([loop/5, upgrade_connection/2, request/5]).
-export([send/3]).
-ifdef(TEST).
-compile(export_all).
-compile([export_all, nowarn_export_all]).
-endif.

loop(Socket, Body, State, WsVersion, ReplyChannel) ->
Expand Down
4 changes: 2 additions & 2 deletions test/mochiweb_base64url_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ id(X) ->
binary_to_list(mochiweb_base64url:encode(binary_to_list(X))))).

random_binary(Short,Long) ->
<< <<(random:uniform(256) - 1)>>
|| _ <- lists:seq(1, Short + random:uniform(1 + Long - Short) - 1) >>.
<< <<(rand:uniform(256) - 1)>>
|| _ <- lists:seq(1, Short + rand:uniform(1 + Long - Short) - 1) >>.

empty_test() ->
id(<<>>).
Expand Down
2 changes: 1 addition & 1 deletion test/mochiweb_http_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ build_headers(Count, Size) ->
AllowedChars = ["a", "b", "c", "1"],
CharFun =
fun(_I, Acc) ->
C = lists:nth(random:uniform(length(AllowedChars)), AllowedChars),
C = lists:nth(rand:uniform(length(AllowedChars)), AllowedChars),
[C|Acc]
end,
FullString = lists:reverse(lists:foldl(CharFun, [], lists:seq(1, Size))),
Expand Down
4 changes: 2 additions & 2 deletions test/mochiweb_test_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
-include("mochiweb_test_util.hrl").
-include_lib("eunit/include/eunit.hrl").


ssl_cert_opts() ->
EbinDir = filename:dirname(code:which(?MODULE)),
CertDir = filename:join([EbinDir, "..", "support", "test-materials"]),
CertDir = filename:join(["support", "test-materials"]),
CertFile = filename:join(CertDir, "test_ssl_cert.pem"),
KeyFile = filename:join(CertDir, "test_ssl_key.pem"),
[{certfile, CertFile}, {keyfile, KeyFile}].
Expand Down
2 changes: 1 addition & 1 deletion test/mochiweb_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ do_POST(Transport, Size, Times) ->
end,
TestReqs = [begin
Path = "/stuff/" ++ integer_to_list(N),
Body = crypto:rand_bytes(Size),
Body = crypto:strong_rand_bytes(Size),
#treq{path=Path, body=Body, xreply=Body}
end || N <- lists:seq(1, Times)],
ClientFun = new_client_fun('POST', TestReqs),
Expand Down