Encrypted XML parsing failed

  • Hello. I'm running into an issue where, after running my XML through the encrypt tool, I will get an XML parsing error maybe about 25% of the time even when using the same XML. These are the steps that generate the XML that I'm using.

    1. Get info about hotspots and scenes from database
    2. Turn that into XML for krpano
    3. Encrypt the XML and then escape the encrypted string
    4. Load the xml string (not a file) in JavaScript with loadxml() call

    For some reason the encryption part seems to cause the parsing to fail sometimes. I've checked the xml before encryption and it is always the same. If I remove encryption step then it is successfully parsed every time. If it is helpful I can send examples of encryption xml that worked and some that failed. I've looked at them side by side and haven't noticed any major differences and as far as I know there is no way to decrypt these to try to find the xml issue.



    Would really appreciate any insight on this.


    Thanks!

  • Update on this. Since there were a lot of places were this could go wrong I tried replacing the generated XML with a hardcoded XML string so I could confirm it's the same every time. I did this and I am still getting the same outcome of a parsing error about 25% of the time. I also tried replacing the hardcoded XML string with '<krpano><preview type="grid();" /></krpano>' and here the encryption worked 100% of the time. So it seems it is related to my XML somehow but it is just inconsistent. Again the unencrypted XML still works 100% of the time. Hopefully that info is helpful.

  • The XML is kind of long but I'll attach it here. The unencrypted.xml is just my default xml that works. Then there are two different encrypted xml files, one which worked and one which gave me the parsing error. Let me know if you need anything else or want additional examples of encrypted files that work/fail. Thanks a lot for taking a look.

  • 1. Tried removing that but doesn't seem to make a difference. Still works on and off.
    2. Since I'm using loadxml with just a string instead of a path to a file I have to escape the string first. To make it easier I'm just escaping the string before storing it so I don't have to do it every time. I tried removing that, which resulting in the normal encrypted xml that you're describing, and then in JavaScript doing loadXml(escape(myXml)) and I got the same outcome of parsing failed every so often.

    I've attached an encrypted file that I didn't escape which gave me an error.

    Edit: I also tried loading that unescaped xml locally directly from a file with the testing server and it still gives a parsing error so it seems there's something else going on.

  • Hmm I took a look and yeah after removing the escaping I'm just taking the encrypted string directly from the krpano encrypt tool without modifying it. I did some more testing this morning though and found that if I use the unecrypted xml I shared previously and run that through the krpano tools encrypt GUI tool it seems to work every time. My code is running it with the command line tool and using stdout instead of writing it to a file. So not sure if that is causing the issue for some reason.

    From the encrypt docs:

    • When using stdout as output filename, the encrypted filedata will be written to the console.


    I'll try experimenting with this and see if it affects my results and post back with more info. Thanks again taking the time to help out.

  • Managed to find a solution for anyone who experiences this issue. I found that if I make a "direct call" to load xml, which I found in this post https://krpano.com/forum/wbb/inde…&threadID=16960, then it works. I hadn't seen this anywhere before but for some reason it fixes it. It works fine whether myXml is escaped or not. This ended up being the only change I needed to make.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!