curiousdannii / parchment

The Interactive Fiction web app
https://iplayif.com
MIT License
424 stars 60 forks source link

Backslash escaping #3

Closed juhana closed 11 years ago

juhana commented 11 years ago

This is a fix to a bug in zvm that causes any backslashes in the story output to be considered as escape characters. \n produces a newline, \\ shows only one backslash etc. \' crashes Parchment completely. See http://iplayif.com/?story=https://dl.dropbox.com/u/27567916/test.z8 for a test case.

juhana commented 11 years ago

Actually this seems to work only with line output. Character output gets stuck printing backslashes indefinitely.

curiousdannii commented 11 years ago

It would be better to fix it in src/structio/api.js I think. The problem is that I didn't realise that jQuery's text() function escapes backslashes. So it should be simple enough to fix it in basic_stream_handler(). Do you want to do it?

curiousdannii commented 11 years ago

Off-topic: you might like to add a comment to http://inform7.uservoice.com/forums/57320-general/suggestions/3608381-run-vm-initialise-as-a-for-starting-the-virtual-ma

juhana commented 11 years ago

I tried it but basic_stream_handler() is too late, the string it receives has already "parsed" the backslashes (the string contains the newline character instead of \ + n, for example). The escaping has to be done in an earlier stage, but I don't know the engine well enough to tell what point that would be.

curiousdannii commented 11 years ago

That should not be the case. Okay, I'll track it down and fix it ASAP.

curiousdannii commented 11 years ago

Moved to http://inform7.com/mantis/view.php?id=1078

curiousdannii commented 11 years ago

Juhana, this seems to fix everything that I've tried. What did you mean by "Character output gets stuck printing backslashes indefinitely" and is it still a problem?

juhana commented 11 years ago

Sorry for the late reply, but this does seem to work, thanks! I'm not using buffering for the Vorple JavaScript stream (although I should) so it prints it out character by character, but even that works with this fix.