privoxy-regression-test.pl: Allow '[' and ']' in URLs
[privoxy.git] / tools / privoxy-regression-test.pl
index c08cc76..69a9ee7 100755 (executable)
@@ -7,8 +7,6 @@
 # A regression test "framework" for Privoxy. For documentation see:
 # perldoc privoxy-regression-test.pl
 #
-# $Id: privoxy-regression-test.pl,v 1.96 2016/05/12 08:42:57 fabiankeil Exp $
-#
 # Wish list:
 #
 # - Update documentation
@@ -40,7 +38,7 @@ use strict;
 use Getopt::Long;
 
 use constant {
-    PRT_VERSION => 'Privoxy-Regression-Test 0.7',
+    PRT_VERSION => 'Privoxy-Regression-Test 0.7.1',
  
     CURL => 'curl',
 
@@ -134,7 +132,7 @@ sub parse_tag ($) {
 sub check_for_forbidden_characters ($) {
 
     my $string = shift;
-    my $allowed = '[-=\dA-Za-z~{}:./();\t ,+@"_%?&*^]';
+    my $allowed = '[-=\dA-Za-z~{}\[\]:./();\t ,+@"_%?&*^]';
 
     unless ($string =~ m/^$allowed*$/o) {
         my $forbidden = $string;
@@ -276,7 +274,7 @@ sub load_regression_tests_from_file ($) {
                 l(LL_FILE_LOADING, "Sticky actions: " . $sticky_actions);
                 $regression_tests[$si][$ri]{'sticky-actions'} = $sticky_actions;
             } else {
-                log_and_die("Sticky URL without Sticky Actions: $value");
+                log_and_die("Sticky URL without Sticky Actions in $action_file: $value");
             }
 
         } else {
@@ -370,8 +368,9 @@ sub tokenize ($) {
 
     my ($token, $value) = (undef, undef);
 
-    # Remove leading and trailing white space.
-    s@^\s*@@;
+    # Remove leading and trailing white space and a
+    # a leading <pre> which is part of the first line.
+    s@^\s*(<pre>)?@@;
     s@\s*$@@;
 
     # Reverse HTML-encoding
@@ -655,7 +654,7 @@ sub load_action_files ($) {
                     l(LL_FILE_LOADING, "Sticky actions: " . $sticky_actions);
                     $regression_tests[$si][$ri]{'sticky-actions'} = $sticky_actions;
                 } else {
-                    log_and_die("Sticky URL without Sticky Actions: $value");
+                    log_and_die("Sticky URL without Sticky Actions in $actionfile: $value");
                 }
 
             } else {
@@ -1453,6 +1452,8 @@ sub get_page_with_curl ($) {
     $curl_line .= " --user-agent '" . PRT_VERSION . "' ";
     # We aren't too patient
     $curl_line .= " --max-time '" . get_cli_option('max-time') . "' ";
+    # We don't want curl to treat "[]", "{}" etc. special
+    $curl_line .= " --globoff ";
 
     $curl_line .= $parameters;
     # XXX: still necessary?
@@ -1912,7 +1913,7 @@ To verify that requests for a URL get redirected, use:
 
 To skip a test, add the following line:
 
-# Ignore = Yes
+    # Ignore = Yes
 
 The difference between a skipped test and a removed one is that removing
 a test affects the numbers of the following tests, while a skipped test
@@ -1925,20 +1926,20 @@ is likely to get lost with the next update.
 
 Overwrite conditions are an alternative and can be added in any action
 file as long as the come after the test that is expected to fail.
-They causes all previous tests a matching the condition to be skipped.
+They cause all previous tests that match the condition to be skipped.
 
 It is recommended to put the overwrite condition below the custom Privoxy
 section that causes the expected test failure and before the custom test
 that verifies that tests the now expected behaviour. Example:
 
-# The following section is expected to overwrite a section in
-# default.action, whose effect is tested. Thus also disable the
-# test that is now expected to fail and add a new one.
-#
-{+block{Facebook makes Firefox even more unstable. Do not want.}}
-# Overwrite condition = http://apps.facebook.com/onthefarm/track.php?creative=&cat=friendvisit&subcat=weeds&key=a789a971dc687bee4c20c044834fabdd&next=index.php%3Fref%3Dnotif%26visitId%3D898835505
-# Blocked URL = http://apps.facebook.com/
-.facebook./
+    # The following section is expected to overwrite a section in
+    # default.action, whose effect is being tested. Thus also disable
+    # the test that is now expected to fail and add a new one.
+    #
+    {+block{Facebook makes Firefox even more unstable. Do not want.}}
+    # Overwrite condition = http://apps.facebook.com/onthefarm/track.php?creative=&cat=friendvisit&subcat=weeds&key=a789a971dc687bee4c20c044834fabdd&next=index.php%3Fref%3Dnotif%26visitId%3D898835505
+    # Blocked URL = http://apps.facebook.com/
+    .facebook./
 
 =head1 TEST LEVELS