awslabs / aws-c-common

Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.
Apache License 2.0
262 stars 159 forks source link

xml_parser does not support empty tags #1165

Closed rvansa closed 1 week ago

rvansa commented 2 weeks ago

Describe the bug

I am trying to connect using aws-c-s3 to a localstack instance. On listing objects in a bucket localstack replies with

<?xml version='1.0' encoding='utf-8'?>
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01\">
  <IsTruncated>false</IsTruncated>
  <Name>foo</Name>
  <Prefix />
  <MaxKeys>1000</MaxKeys>
  <EncodingType>url</EncodingType>
  <KeyCount>1</KeyCount>
  <Contents> (redacted) </Contents>
</ListBucketResult>

but xml_parser is unable to parse empty tag <Prefix />: it ignores that it is an empty tag and looks for </Prefix>, failing to parse the document.

Regression Issue

Expected Behavior

Valid XML is parsed.

Current Behavior

Parser logs XML document is invalid. and returns error.

Reproduction Steps

Try to parse

<?xml version='1.0' encoding='utf-8'?>
<foo><bar /></foo>

Possible Solution

No response

Additional Information/Context

No response

aws-c-common version used

v0.9.27

Compiler and version used

GCC 11.2

Operating System and version

Linux

jmklix commented 1 week ago

Thanks for finding this bug. We have a PR that should fix this: https://github.com/awslabs/aws-c-common/pull/1168