Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
z_stdlib
z_stdlib-1.0.0-git.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File z_stdlib-1.0.0-git.patch of Package z_stdlib
diff --git a/src/z_jsmin.erl b/src/z_jsmin.erl index e5fc00c..0a04363 100644 --- a/src/z_jsmin.erl +++ b/src/z_jsmin.erl @@ -27,7 +27,7 @@ -define(is_alnum(C), ( (C >= $a andalso C =< $z) orelse - (C >= $A andalso C =< $A) orelse + (C >= $A andalso C =< $Z) orelse (C >= $0 andalso C =< $9) orelse C =:= $_ orelse C =:= $\\ orelse C =:= $$ orelse C > 126)). @@ -117,7 +117,7 @@ regexp(<<C, JS/binary>>, Acc) -> regexp_set(<<$], JS/binary>>, Acc) -> {JS, [ $] | Acc ]}; regexp_set(<<$\\, C, JS/binary>>, Acc) -> - regexp_set(JS, [ C, $\\, Acc ]); + regexp_set(JS, [ C, $\\ | Acc ]); regexp_set(<<C, JS/binary>>, Acc) -> regexp_set(JS, [ C | Acc ]); regexp_set(<<>>, _Acc) -> diff --git a/src/z_string.erl b/src/z_string.erl index d1da944..1e8d2f9 100644 --- a/src/z_string.erl +++ b/src/z_string.erl @@ -759,6 +759,8 @@ s_utf8(<<>>, Acc) -> Acc; %% 1 byte +s_utf8(<<0, Rest/binary>>, Acc) -> + s_utf8(Rest, Acc); s_utf8(<<X, Rest/binary>>, Acc) when X < 128 -> s_utf8(Rest, <<Acc/binary, X>>); diff --git a/test/z_jsmin_test.erl b/test/z_jsmin_test.erl index 3f17960..7b457af 100644 --- a/test/z_jsmin_test.erl +++ b/test/z_jsmin_test.erl @@ -80,6 +80,8 @@ re_nl_if_test() -> "if (1) { console.log(2); }"], ?assertEqual(<<"var re=/\\d{4}/\nif(1){console.log(2);}">>, minify_multi_line(Lines)). +backslash_in_re_test() -> + ?assertEqual(<<"foobar=/a[\\b]c/">>, minify(<<"foobar = /a[\\b]c/">>)). copyright_comment_test() -> ?assertEqual(<<"/*! hello */\na;b">>, minify(<<"/*! hello */\na;\nb">>)). @@ -89,10 +91,13 @@ char_from_return_test() -> ?assertEqual(<<"return r/1;">>, minify(<<"return r / 1;">>)). precedence_of_parens_test() -> - ?assertEqual(<<"/a([)])b/g">>, <<"/a([)])b/g">>), - ?assertEqual(<<"/a[(]b/g">>, <<"/a[(]b/g">>), + ?assertEqual(<<"/a([)])b/g">>, minify(<<"/a([)])b/g">>)), + ?assertEqual(<<"/a[(]b/g">>, minify(<<"/a[(]b/g">>)), ok. +instanceof_test() -> + ?assertEqual(<<"a instanceof Object">>, minify(<<"a instanceof Object">>)). + %% %% Helpers diff --git a/test/z_string_sanitize_utf8_test.erl b/test/z_string_sanitize_utf8_test.erl index a31b2ef..917d5c7 100644 --- a/test/z_string_sanitize_utf8_test.erl +++ b/test/z_string_sanitize_utf8_test.erl @@ -53,14 +53,15 @@ s_utf8a() -> ). %% @doc For every random binary if unicode.erl claims it's utf8, -%% s_utf agrees +%% s_utf agrees. s_utf8b() -> ?FORALL( ProbablyUtf8, ?SUCHTHAT( B, binary(), - unicode:characters_to_binary(B) == B), + unicode:characters_to_binary(B) == B + andalso no_ill_codepoint(B)), v_utf8(ProbablyUtf8) ). @@ -85,6 +86,12 @@ utf8_string() -> iolist_to_binary(CodePoints) ). +%% @doc Check if there is not an illegal codepoint. +no_ill_codepoint(B) -> + binary:match(B, <<0>>) == nomatch + andalso binary:match(B, <<239,191,190>>) == nomatch + andalso binary:match(B, <<239,191,191>>) == nomatch. + %% @doc Generate a codepoint of max Len bytes in length -spec gen_codepoint(pos_integer(), [proper_types:type(), ...]) -> proper_types:type(). @@ -100,7 +107,7 @@ gen_codepoint(2, Acc) -> gen_codepoint(1, [{integer(16#80, 16#7FF), 2}|Acc]); gen_codepoint(1, Acc) -> - union([{integer(0, 16#7F), 1}|Acc]). + union([{integer(1, 16#7F), 1}|Acc]). utf8_codepoint() -> utf8_codepoint(4). @@ -112,6 +119,8 @@ utf8_codepoint(MaxLen) -> {Codepoint, Octets}, gen_codepoint(MaxLen, []), case Octets of + _ when Codepoint == 0; Codepoint == 16#fffe; Codepoint == 16#ffff -> + <<1:8>>; 1 -> <<Codepoint:8>>; 2 ->
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor