Skip to content

[critical] mpgResponse XML parse bug #3

Open
@cyveros

Description

@cyveros

@MonerisSolutions
I find a critical bug within mpgResponse class.

The XML parser "failed" on identifying special XML entity character '&'. For example, we expect

<ACSUrl>https://host/path?item1=1&amp;item2=2</ACSUrl>

to be parsed as:

['ACSUrl' => 'https://host/path?item1=1&amp;item2=2']

However, the actual outcome is:

['ACSUrl' => 'item2=2']

The cause of this bug is within method mpgResponse::characterHandler($parser, $data)

Due to '&' as an special XML entity character, the 'data node':

https://host/path?item1=1&amp;item2=2

is tokenized into 3 separate fields:

https://host/path?item1=1
&
item2=2

It means mpgResponse::characterHandler would be invoked three times by php xml parser although the currentTag remain unchanged across these 3 times function calls.

Near the end of mpgResponse::characterHandler, there is a statement

$this->responseData[$this->currentTag] = $data;

So, the later tokenized string will overwrite the previous one. This explain the bug.
In fact, all 5 special xml entity characters will cause this bug.

Thus, I propose to concatenate the tokenized data string instead

$this->responseData[$this->currentTag]  .= $data;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions