• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

packages/apps/AndroidTerm


Commit MetaInfo

Revision14c7cebbafa3c8806252db3830dad478e33f5113 (tree)
Zeit2012-03-26 10:21:37
AutorSteven Luo <steven+android@stev...>
CommiterJack Palevich

Log Message

Properly handle UTF-8 sequences decoding to C1 control characters

Applications which emit UTF-8 sequences that decode to C1 control
characters expect these sequences to be interpreted as C1 control
characters, so send them back through process() instead of trying to
emit them.

Signed-off-by: Jack Palevich <jackpal@google.com>

Ändern Zusammenfassung

Diff

--- a/src/jackpal/androidterm/session/TerminalEmulator.java
+++ b/src/jackpal/androidterm/session/TerminalEmulator.java
@@ -515,8 +515,12 @@ public class TerminalEmulator {
515515 }
516516
517517 private void process(byte b) {
518+ process(b, true);
519+ }
520+
521+ private void process(byte b, boolean doUTF8) {
518522 // Let the UTF-8 decoder try to handle it if we're in UTF-8 mode
519- if (mUTF8Mode && handleUTF8Sequence(b)) {
523+ if (doUTF8 && mUTF8Mode && handleUTF8Sequence(b)) {
520524 return;
521525 }
522526
@@ -654,7 +658,15 @@ public class TerminalEmulator {
654658 decoder.reset();
655659 decoder.decode(byteBuf, charBuf, true);
656660 decoder.flush(charBuf);
657- emit(charBuf.array());
661+
662+ char[] chars = charBuf.array();
663+ if (chars[0] >= 0x80 && chars[0] <= 0x9f) {
664+ /* Sequence decoded to a C1 control character which needs
665+ to be sent through process() again */
666+ process((byte) chars[0], false);
667+ } else {
668+ emit(chars);
669+ }
658670
659671 byteBuf.clear();
660672 charBuf.clear();