Fix Base64 output from /exec on webOS 1 #178
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While #172 fixed the basic functionality of
/exec
on webOS 1, the Base64 fields of the response (stdoutBytes
andstderrBytes
) were not working as intended.On Node.js v0.10.x,
child_process.exec()
doesn't appear to support passing stdout and stderr asBuffer
objects to the callback. However, thebinary
encoding (an alias forlatin1
) can be used to get strings containing the raw program output. After creatingBuffer
s from the strings, the data can be handled the same as on newer webOS/Node.js versions.Testing
I verified that responses containing UTF-8 encoded data were handled identically between webOS 1 and 8.
webOS 8.1.0:
webOS 1.4.0:
/home/root/utf8.sh
just outputs UTF-8 encoded text on stdout and stderr. The original files in Base64 form are0rvIheG4veG4u/CdlpQg8J2Zm9Cz4buV4bi/IOqeqcat4ZGv8J2evMqL8J2ZqQo=
(stdout) andyJ/EmeG4vcaa4rKfIOG1rvCdk7vFkeG5gSDqnLHwnZaZ4biT8J2ShvCdlpfwnZeLCg==
(stderr). They were received unmodified on both webOS 1 and 8.I also checked that a chunk of data from
/dev/urandom
made it through unchanged on webOS 1.Limitations
/exec
still doesn't behave exactly the same on all webOS versions. I have noticed thaterrorText
is different, as can be seen with thefalse
command.webOS 8.1.0:
webOS 1.4.0:
In seems later versions generally include the failed command itself, while webOS 1 does not. This is not something we can easily change, though, and it is probably not that important.