Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[critical] mpgResponse XML parse bug #3

Open
cyveros opened this issue Jan 11, 2017 · 0 comments
Open

[critical] mpgResponse XML parse bug #3

cyveros opened this issue Jan 11, 2017 · 0 comments

Comments

@cyveros
Copy link

cyveros commented Jan 11, 2017

@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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant