aboutsummaryrefslogtreecommitdiff
path: root/tests/getpart.pm
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-03-10 17:47:44 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-03-13 11:03:42 +0100
commitfe8ba51209959c6ff200b4f7c847c7a3fc53ecfa (patch)
tree4e61ae8c2f06a8537017528b1002aadddee358dd /tests/getpart.pm
parenta7e24c736267d0cbf9ab2eedf2027b7d26e317bb (diff)
server/getpart: make the "XML-parser" stricter
When extracting a <section> <part> and there's no </part> before </section>, this now outputs an error and returns a wrong string to make users spot the mistake. Ref: #5070 Closes #5071
Diffstat (limited to 'tests/getpart.pm')
-rw-r--r--tests/getpart.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/getpart.pm b/tests/getpart.pm
index 7080bf4b7..cd3b9e556 100644
--- a/tests/getpart.pm
+++ b/tests/getpart.pm
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2020, 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
@@ -23,6 +23,7 @@
#use strict;
my @xml;
+my $xmlfile;
my $warning=0;
my $trace=0;
@@ -80,11 +81,10 @@ sub getpart {
my @this;
my $inside=0;
my $base64=0;
-
- # print "Section: $section, part: $part\n";
+ my $line;
for(@xml) {
- # print "$inside: $_";
+ $line++;
if(!$inside && ($_ =~ /^ *\<$section/)) {
$inside++;
}
@@ -105,6 +105,10 @@ sub getpart {
$inside--;
}
elsif(($inside >= 1) && ($_ =~ /^ *\<\/$section/)) {
+ if($inside > 1) {
+ print STDERR "$xmlfile:$line:1: error: missing </$part> tag before </$section>\n";
+ @this = ("format error in $xmlfile");
+ }
if($trace && @this) {
print STDERR "*** getpart.pm: $section/$part returned data!\n";
}
@@ -165,6 +169,7 @@ sub loadtest {
my ($file)=@_;
undef @xml;
+ $xmlfile = $file;
if(open(XML, "<$file")) {
binmode XML; # for crapage systems, use binary