The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

[Python] Random XML datafeed errors

jaushmanjaushman Member
in Help edited February 2009
I've finally got a stable Python port of the PHP script FC provides up and running. However, only 99% of the data is decrypting correctly. I have a few incorrect characters that show up and my XML parser breaks when opening and closing tags don't match.

An example (errors in first and third lines):

When I encrypt/decrypt locally with the PHP or Python scripts I don't see the error. The error occurs when I decrypt the XML datafeed that FC sends me.

I've also tried using the python script that Fred provides in Integration, but I receive the same errors.

It appears to be random and only affects my tests the data between tags doesn't seem to be having issues.

I'm capturing the data and then using urllib.unquote() to decode the url-encoding:
data = request.POST["FoxyData"]
data = urllib.unquote(data)

That "data" variable is then passed off for decryption and storage/processing.

Any ideas?
  • fredfred FoxyCart Team
    Without pulling up my script for further testing, I think the problem is coming from your call to
    before decrypting the data. RC4 is a binary stream cypher, and URL-decoding the string before decryption could be causing your pain.

    I'm going to run through the Python code that I posted against a live store and see what's going on.
  • fredfred FoxyCart Team
    Disregard my previous comment -- you're handling the FoxyData variable precisely right.

    I'm getting the exact same problem when I decrypt the feed coming from Foxycart, and I really don't know the cause. It bears further investigation; I'll look into it tomorrow after I get a fresh start.
  • fredfred FoxyCart Team
    OK, after further testing and debugging the problem lies with
    -- it doesn't handle characters outside of the normal ASCII range by default. The solution is to use
    to decode the string before decrypting with RC4. Give that a try and let us know how it works.
  • Perfect, Fred. I looked at that function a couple of times the last few days and the documentation I came across only noted the exception it makes for spaces. I can't believe that was it...

    You guys rock!!
Sign In or Register to comment.