diff options
author | Yang Tse <yangsita@gmail.com> | 2012-06-20 20:13:07 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2012-06-20 20:14:53 +0200 |
commit | 07086c9487540d792f84d6d84687a6c986f9b138 (patch) | |
tree | 1447d9db4c11c5421fea2d52546e74ad361dce1e /tests/getpart.pm | |
parent | 066811592dbcd49bc36294b244ad64ea08b6fa15 (diff) | |
download | curl-07086c9487540d792f84d6d84687a6c986f9b138.tar.gz |
getpart.pm: make test definition section/part parser more robust
Test definition section parts which needed to include xml-lingo as contents
of that part required that the xml-blurb was written as a single line. Now the
xml-data inside the part can be written multiline making it more readable.
Tested with <client><file> part which is written to disk before <command> runs.
Diffstat (limited to 'tests/getpart.pm')
-rw-r--r-- | tests/getpart.pm | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/tests/getpart.pm b/tests/getpart.pm index d9510dd20..3e9c5a4d5 100644 --- a/tests/getpart.pm +++ b/tests/getpart.pm @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -88,21 +88,27 @@ sub getpart { if(!$inside && ($_ =~ /^ *\<$section/)) { $inside++; } - elsif((1 ==$inside) && ($_ =~ /^ *\<$part[ \>]/)) { - if($_ =~ /$part [^>]*base64=/) { - # attempt to detect base64 encoded parts + elsif(($inside >= 1) && ($_ =~ /^ *\<$part[ \>]/)) { + if($inside > 1) { + push @this, $_; + } + elsif($_ =~ /$part [^>]*base64=/) { + # attempt to detect our base64 encoded part $base64=1; } $inside++; } - elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) { + elsif(($inside >= 2) && ($_ =~ /^ *\<\/$part[ \>]/)) { + if($inside > 2) { + push @this, $_; + } $inside--; } - elsif((1==$inside) && ($_ =~ /^ *\<\/$section/)) { - if($trace) { + elsif(($inside >= 1) && ($_ =~ /^ *\<\/$section/)) { + if($trace && @this) { print STDERR "*** getpart.pm: $section/$part returned data!\n"; } - if(!@this && $warning) { + if($warning && !@this) { print STDERR "*** getpart.pm: $section/$part returned empty!\n"; } if($base64) { @@ -114,14 +120,21 @@ sub getpart { } return @this; } - elsif(2==$inside) { + elsif($inside >= 2) { push @this, $_; } } - if($warning) { + if($trace && @this) { + # section/part has data but end of section not detected, + # end of file implies end of section. + print STDERR "*** getpart.pm: $section/$part returned data!\n"; + } + if($warning && !@this) { + # section/part does not exist or has no data without an end of + # section; end of file implies end of section. print STDERR "*** getpart.pm: $section/$part returned empty!\n"; } - return @this; #empty! + return @this; # empty when end of section detected } sub partexists { |