4
%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
21
-export([all/1, pcre/1,compile_options/1,run_options/1,combined_options/1,replace_autogen/1,global_capture/1,replace_return/1,split_autogen/1,split_options/1,split_specials/1,error_handling/1]).
21
-export([all/1, pcre/1,compile_options/1,run_options/1,combined_options/1,replace_autogen/1,global_capture/1,replace_input_types/1,replace_return/1,split_autogen/1,split_options/1,split_specials/1,error_handling/1,pcre_cve_2008_2371/1]).
23
23
-include("test_server.hrl").
24
24
-include_lib("kernel/include/file.hrl").
26
all(suite) -> [pcre,compile_options,run_options,combined_options,replace_autogen,global_capture,replace_return,split_autogen,split_options,split_specials,error_handling].
26
all(suite) -> [pcre,compile_options,run_options,combined_options,replace_autogen,global_capture,replace_input_types,replace_return,split_autogen,split_options,split_specials,error_handling,pcre_cve_2008_2371].
29
29
["Run all applicable tests from the PCRE testsuites."];
268
268
?line {match,[[{3,5},{5,3}],[{11,4},{12,3}]]} = re:run("ABC�bcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,index},unicode]),
269
269
?t:timetrap_cancel(Dog),
272
replace_input_types(doc) ->
273
["Tests replace with different input types"];
274
replace_input_types(Config) when is_list(Config) ->
275
Dog = ?t:timetrap(?t:minutes(3)),
276
?line <<"abcd">> = re:replace("abcd","Z","X",[{return,binary},unicode]),
277
?line <<"abcd">> = re:replace("abcd","\x{400}","X",[{return,binary},unicode]),
278
?line <<"a",208,128,"cd">> = re:replace(<<"abcd">>,"b","\x{400}",[{return,binary},unicode]),
279
?t:timetrap_cancel(Dog),
272
282
replace_return(doc) ->
273
283
["Tests return options of replace together with global searching"];
274
284
replace_return(Config) when is_list(Config) ->
289
299
?line <<"iXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\9X",[{return,binary}]),
290
300
?line <<"jXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\10X",[{return,binary}]),
291
301
?line <<"Xk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\11X",[{return,binary}]),
302
?line "a\x{400}bcX" = re:replace("a\x{400}bcd","d","X",[global,{return,list},unicode]),
303
?line <<"a",208,128,"bcX">> = re:replace("a\x{400}bcd","d","X",[global,{return,binary},unicode]),
304
?line "a\x{400}bcd" = re:replace("a\x{400}bcd","Z","X",[global,{return,list},unicode]),
305
?line <<"a",208,128,"bcd">> = re:replace("a\x{400}bcd","Z","X",[global,{return,binary},unicode]),
292
306
?t:timetrap_cancel(Dog),
524
538
?t:timetrap_cancel(Dog),
541
pcre_cve_2008_2371(doc) ->
542
"Fix as in http://vcs.pcre.org/viewvc?revision=360&view=revision";
543
pcre_cve_2008_2371(Config) when is_list(Config) ->
544
%% Make sure it doesn't crash the emulator.
545
re:compile(<<"(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]">>, [unicode]),