To reproduce: pd-l2ork /usr/lib/pd-l2ork/extra/flext/fluid~-help.pd. The patch never opens. Output in pd console and terminal (stdout and stderr) is attached. The error message near the end of the terminal log seems to be related.console.txtterminal.txt
Ok, this one is fixed now, but cyclone is still giving similar errors. In particular, the seq-help patch never opens. To reproduce: pd-l2ork /usr/lib/pd-l2ork/extra/cyclone/seq-help.pd
Terminal log:
gui_legacy_tcl_command("../shared/hammer/file.c",73,"text $name.text -relief sunken -bd 1 \"); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^SyntaxError: Invalid or unexpected token at Socket.perfect_parser (/usr/lib/pd-l2ork/bin/pdgui.js:1195:44) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:172:18) at Socket.Readable.push (_stream_readable.js:130:10) at TCP.onread (net.js:542:20)
Sounds plausible. I could modify the code so that it takes care of \ immediately preceding newline.
But I think that real culprit is the gui_vmess() function here. Shouldn't it be able to deal with whatever C string arguments you pass? Or are the strings assumed to already be in proper JS syntax, escapes and all that? That would be a bad idea IMHO.
Double quotes are string delimiters-- all double quotes inside the string are escaped on the C side before sending over the socket
ASCII 31 (unit separator) delimits messages, since a single-byte delimiter means one less thing to think about when I wrote the GUI-side parser.
It's not even JSON, but a quick-and-dirty format that lends itself to being plugged in to Javascript's "eval" function. It works because there hasn't been a single case where I needed to send a "" or a unit separator to the GUI.
So in this case, the trailing "" ends up escaping the string delimiter, and Javascript complains when it hits a newline.
If you want to make gui_vmess absolutely bullet-proof, feel free. The easier route is to only send the filename and line number to the GUI, or limit the legacy string to alpha-numeric data.
I think that the attached patch for escape_double_quotes should fix the problem. The idea is to escape both" and \ (if you do one, you also have to do the other). Caveat: I'm not at my Linux box right now, so this is completely untested. But I can do that tonight.