xsank / webssh

WebSSH is a simple web project which support login linux server with explorer.
http://xsank.github.io/webssh/
MIT License
580 stars 221 forks source link

处理含中文的文件,但是文件字符集为iso88591的时候,程序直接close #10

Open someonebw opened 8 years ago

someonebw commented 8 years ago

test-iso88591.txt: text/plain; charset=iso-8859-1 test-utf-8.txt: text/plain; charset=utf-8 [root@node96 test]# hexdump -C test-utf-8.txt 00000000 74 65 73 74 c3 96 c3 90 |test....| 00000008 [root@node96 test]# hexdump -C test-iso88591.txt 00000000 74 65 73 74 d6 d0 |test..| 00000006

在页面上面会报错,websocket被close

WebSocket connection to 'ws://x.x.x.x:9527/ws' failed: Could not decode a text frame as UTF-8.

xsank commented 8 years ago

![Uploading tmp.jpg…]() 我这里是可以的,还有别的条件吗?

xsank commented 8 years ago

`[xsank.mz@myhost /home/xsank.mz]
$hexdump -C testdd.txt
00000000 a1 09 69 6e 76 65 72 74 65 64 20 65 78 63 6c 61 |..inverted excla|
00000010 6d 61 74 69 6f 6e 20 6d 61 72 6b 09 26 69 65 78 |mation mark.&iex|
00000020 63 6c 3b 09 26 23 31 36 31 3b 0a a2 09 63 65 6e |cl;.¡...cen|
00000030 74 09 26 63 65 6e 74 3b 09 26 23 31 36 32 3b 0a |t.¢.¢.|
00000040 a3 09 70 6f 75 6e 64 09 26 70 6f 75 6e 64 3b 09 |..pound.£.|
00000050 26 23 31 36 33 3b 0a a4 0a |£...|
00000059

[xsank.mz@myhost /home/xsank.mz]
$file -bi testdd.txt
text/plain; charset=iso-8859-1

[xsank.mz@myhost /home/xsank.mz]
$ `

someonebw commented 8 years ago

[root@node96 ~]# env |grep LANG LANG=zh_CN.UTF-8 [root@node96 ~]# python Python 2.7.9 (default, Nov 5 2015, 10:01:01) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

[root@node96 ~]# uname -r 2.6.32-431.el6.x86_64 [root@node96 ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [root@node96 ~]# cat /tmp/test/test-utf-8.txt testÖÐ[root@node96 ~]# cat /tmp/test/test-iso88591.txt testא[root@node96 ~]#

我的环境,没有啥特殊的地方了.

someonebw commented 8 years ago

qq 20160202095559

我的场景截图

someonebw commented 8 years ago

test-iso88591.txt test-utf-8.txt

我测试的2个文件.

someonebw commented 8 years ago

场景截图 qq 20160202100058

someonebw commented 8 years ago

场景截图 qq 20160202100204

xsank commented 8 years ago

看起来是websocket客户端收到非utf-8编码时自己主动close的,白天工作比较苦逼,晚上我查查这个问题

someonebw commented 8 years ago

行,xsank,辛苦了.:)

xsank commented 8 years ago

看起来在javascript的websocket的onmessage方法中是没办法处理这个问题的,这个方法收到的数据已经是parse过frame的数据了,抛错在此方法之前

临时解决方案: 服务器端添加chardet模块来校验发送的数据类型,如果数据非UTF-8编码则声明websocket不支持,亲测可行 暂时没想到好的方案,先不提交代码

xsank commented 8 years ago

utf-8编码应该是支持websocket的浏览器硬性要求的,目前只能应用层处理或者换修复此问题的浏览器

someonebw commented 8 years ago

亲测了这个example,好像没有这个编码的问题. https://github.com/chjj/term.js/blob/master/example/index.js 不知道对你有没有帮助!

someonebw commented 8 years ago

继续关注......

xsank commented 8 years ago

好的,刚开始上班,这周应该有空的,你说的这个例子我看看

someonebw commented 8 years ago

我试了下这个插件,貌似也没有编码方面的问题(还支持复制,粘贴).好像是基于hterm开发的.也是脚本实现的.非term.js

https://github.com/chromium/hterm

someonebw commented 8 years ago

我试了下这个插件,貌似也没有编码方面的问题(还支持复制,粘贴).好像是基于hterm开发的.也是脚本实现的.非term.js

https://github.com/chromium/hterm

someonebw commented 8 years ago

chrome 插件 https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo

someonebw commented 8 years ago

这个好像是基于hterm开发的

https://github.com/krishnasrinivas/wetty

someonebw commented 8 years ago

給你发了,关于hterm的mail,请查收.供参考.

someonebw commented 8 years ago

如何了@xsank

anythingwhat commented 6 years ago

中文字符编码不是utf-8,程序直接close的问题,求指教@someonebw,@xsank