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

fillField function adds backslashes to an XML feed #62

Open
smrpr opened this issue Apr 28, 2014 · 2 comments
Open

fillField function adds backslashes to an XML feed #62

smrpr opened this issue Apr 28, 2014 · 2 comments

Comments

@smrpr
Copy link

smrpr commented Apr 28, 2014

When trying to fill a textbox with an XML I provide, the pasted text is not my original XML, but the XML with backslashes added before the double-quotes.

I've opened a question in StackOverflow with further info:

http://stackoverflow.com/questions/23336764/mink-xml-handling-not-as-expected-adds-backslashes-to-feed

@stof
Copy link
Member

stof commented Apr 28, 2014

Can you build a small reproducing testcase ?

@aik099
Copy link
Member

aik099 commented Aug 17, 2014

Here is the example code (copied over from StackOverflow discussion):

public function replaceField($field)
    {
        $baseText = '<?xml version="1.0" encoding="UTF-8"?>
<RiskAssessmentReply xmlns="http://test.com" >
    <!-- ExternalId of the Order --> 
    <OrderId>TO_REPLACE</OrderId>
    <RiskInfo>
        <Actions>
            <SystemAction>SystemAction</SystemAction>
            <FinalAction>FinalAction</FinalAction>
        </Actions>
        <Score SystemScore="0"/>
    </RiskInfo>
    <!-- One of Accept, Manual_Accept, Reject, Cancel, or Ignore --> 
    <ResponseCode>Accept</ResponseCode>
    <StoreId>TESTSTORE</StoreId>
</RiskAssessmentReply>';

        $textWithOrderId = preg_replace('/TO_REPLACE/', $GLOBALS['ORDER_ID'], $baseText);
        $this->getSession()->getPage()->fillField($field, $textWithOrderId);
    }

Then form gets submitted and back in PHP @samuel-redsauce is getting <?xml version=\"1.0\" encoding=\"UTF-8\"?> (note extra \ before ") instead of <?xml version="1.0" encoding="UTF-8"?>.

It's either US encoding given value in the odd manner (should have used htmlspecialchars not addslashes) or it's DomCrawler messing with it. Either way it needs to be investigated.

In meanwhile @samuel-redsauce have used stripcslashes on that fields value in $_POST and no longer have this issue obviously.

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

3 participants