[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 11/264: server/getpart: make the "XML-parser" stricter
From: |
gnunet |
Subject: |
[gnurl] 11/264: server/getpart: make the "XML-parser" stricter |
Date: |
Thu, 30 Apr 2020 16:05:14 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit fe8ba51209959c6ff200b4f7c847c7a3fc53ecfa
Author: Daniel Stenberg <address@hidden>
AuthorDate: Tue Mar 10 17:47:44 2020 +0100
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
---
tests/curl_test_data.py | 6 +++---
tests/data/test1451 | 14 +++++++++-----
tests/getpart.pm | 13 +++++++++----
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/tests/curl_test_data.py b/tests/curl_test_data.py
index 21747407d..f5ce533da 100755
--- a/tests/curl_test_data.py
+++ b/tests/curl_test_data.py
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-#
+# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 2017, Daniel Stenberg, <address@hidden>, et al.
+# Copyright (C) 2017 - 2020, Daniel Stenberg, <address@hidden>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -30,7 +30,7 @@ import logging
log = logging.getLogger(__name__)
-REPLY_DATA = re.compile("<reply>\s*<data>(.*?)</data>", re.MULTILINE |
re.DOTALL)
+REPLY_DATA = re.compile("<reply>[ \t\n\r]*<data[^<]*>(.*?)</data>",
re.MULTILINE | re.DOTALL)
class TestData(object):
diff --git a/tests/data/test1451 b/tests/data/test1451
index 0c114e186..a98e24ec6 100644
--- a/tests/data/test1451
+++ b/tests/data/test1451
@@ -8,7 +8,9 @@ SMB
#
# Server-side
<reply>
-<data>Basic SMB test complete</data>
+<data nocheck="yes">
+Basic SMB test complete
+</data>
</reply>
#
@@ -20,10 +22,10 @@ smb
<features>
smb
</features>
- <name>
+<name>
Basic SMB request
- </name>
- <command>
+</name>
+<command>
-u 'curltest:curltest' smb://%HOSTIP:%SMBPORT/TESTS/1451
</command>
</client>
@@ -31,6 +33,8 @@ Basic SMB request
#
# Verify data after the test has been "shot"
<verify>
-<stdout>Basic SMB test complete</stdout>
+<stdout>
+Basic SMB test complete
+</stdout>
</verify>
</testcase>
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, <address@hidden>, et al.
+# Copyright (C) 1998 - 2020, Daniel Stenberg, <address@hidden>, 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
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 07/264: smbserver: fix Python version specific ConfigParser import, (continued)
- [gnurl] 07/264: smbserver: fix Python version specific ConfigParser import, gnunet, 2020/04/30
- [gnurl] 01/264: configure: document 'compiler_num' for gcc, gnunet, 2020/04/30
- [gnurl] 03/264: configure: convert -I to -isystem as a last step, gnunet, 2020/04/30
- [gnurl] 02/264: configure: fix -pedantic-errors for GCC 5 and later, gnunet, 2020/04/30
- [gnurl] 04/264: Makefile: run the cd commands in a subshell, gnunet, 2020/04/30
- [gnurl] 06/264: RELEASE-NOTES: synced, gnunet, 2020/04/30
- [gnurl] 09/264: smbserver: pin Python version to 2 since we are not yet 3 compatible, gnunet, 2020/04/30
- [gnurl] 10/264: impacket: some more Python 3 code compatibility updates, gnunet, 2020/04/30
- [gnurl] 08/264: cleanup: fix some text/comment typos, gnunet, 2020/04/30
- [gnurl] 05/264: tests/data: Fix some XML formatting issues in test cases, gnunet, 2020/04/30
- [gnurl] 11/264: server/getpart: make the "XML-parser" stricter,
gnunet <=
- [gnurl] 13/264: easy: Fix curl_easy_duphandle for builds missing IPv6 that use c-ares, gnunet, 2020/04/30
- [gnurl] 17/264: ci/tests: fix and align setting TFLAGS for make test-nonflaky, gnunet, 2020/04/30
- [gnurl] 14/264: Makefile.m32: Improve windres parameter compatibility, gnunet, 2020/04/30
- [gnurl] 19/264: select: move duplicate select preparation code into Curl_select, gnunet, 2020/04/30
- [gnurl] 24/264: tests/README: add note about manually installing python-impacket, gnunet, 2020/04/30
- [gnurl] 23/264: transfer: cap retries of "dead connections" to 5, gnunet, 2020/04/30
- [gnurl] 25/264: ci/tests: install impacket for SMB tests on FreeBSD using CirrusCI, gnunet, 2020/04/30
- [gnurl] 20/264: select: fix 'pending_ms' is assigned a value that is never used, gnunet, 2020/04/30
- [gnurl] 27/264: gskit: use our internal select wrapper for portability, gnunet, 2020/04/30
- [gnurl] 29/264: ci/tests: fix Azure Pipelines not running for pull requests, gnunet, 2020/04/30