masuilab / Gyazz

Node+Express+MongoDBによるGyazzの再実装
22 stars 1 forks source link

ページ名頭に@が付く時、Socket.IOの接続先ホスト名がおかしくなる #213

Closed shokai closed 9 years ago

shokai commented 9 years ago

このページでsocket.ioが接続できない また、サーバー側もnodeプロセスが強制終了する http://gyazz.masuilab.org/osusume/@shokai/masuilab%20on%20Twitter

screen shot

Error: Bad Request
  at SendStream.error (/Users/masui/Gyazz/node_modules/express/node_modules/send/index.js:239:16)
  at SendStream.pipe (/Users/masui/Gyazz/node_modules/express/node_modules/send/index.js:411:32)
  at serveStatic (/Users/masui/Gyazz/node_modules/express/node_modules/serve-static/index.js:107:12)
  at Layer.handle [as handle_request] (/Users/masui/Gyazz/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:270:13)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:312:12)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:295:3)
  at next (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:189:10)
  at favicon (/Users/masui/Gyazz/node_modules/serve-favicon/index.js:59:44)
  at Layer.handle [as handle_request] (/Users/masui/Gyazz/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:270:13)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:312:12)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:295:3)
  at next (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:189:10)
  at expressInit (/Users/masui/Gyazz/node_modules/express/lib/middleware/init.js:23:5)
  at Layer.handle [as handle_request] (/Users/masui/Gyazz/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:270:13)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:312:12)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:295:3)
  at next (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:189:10)
  at query (/Users/masui/Gyazz/node_modules/express/lib/middleware/query.js:28:5)
  at Layer.handle [as handle_request] (/Users/masui/Gyazz/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:270:13)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:312:12)
  at /Users/masui/Gyazz/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:295:3)
  at next (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/Users/masui/Gyazz/node_modules/express/lib/router/index.js:165:3)
  at Function.app.handle (/Users/masui/Gyazz/node_modules/express/lib/application.js:141:10)
  at Server.app (/Users/masui/Gyazz/node_modules/express/lib/express.js:28:9)
  at Server.<anonymous> (/Users/masui/Gyazz/node_modules/socket.io/node_modules/engine.io/lib/server.js:369:22)
  at Server.<anonymous> (/Users/masui/Gyazz/node_modules/socket.io/lib/index.js:257:16)
  at Server.emit (events.js:98:17)
  at HTTPParser.parser.onIncoming (http.js:2108:12)
  at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
  at Socket.socket.ondata (http.js:1966:22)
  at TCP.onread (net.js:527:27)
shokai commented 9 years ago

どうやらページ名頭に @ が付くページで起るらしい

http://gyazz.masuilab.org/osusume/@shokai http://node-gyazz.herokuapp.com/shokai/@hoge

nekobato commented 9 years ago

encodeURIは@を変換してくれません。 encodeURIComponentを使いましょう。

https://github.com/masuilab/Gyazz/blob/master/public/javascripts/gyazz_edit.coffee#L1 https://github.com/masuilab/Gyazz/blob/master/public/javascripts/gyazz_socket.coffee#L4

masui commented 9 years ago

nekobato氏の提案どおり修正しました @5c4b4ff

masui commented 9 years ago

ページ名が「@」ではじまってるページはタイトルクリックしてもテキスト編集できないのか?

masui commented 9 years ago

Chromeだと大丈夫だけどFirefoxだと編集できない??

shokai commented 9 years ago

デバッグコンソールを使えばいいのでは jsエラーが出ていればエラーは見えるし、そうでなければDOMがおかしくなっているはずです

shokai commented 9 years ago

jQuery.paramを使えばobjectをまとめてencodeURIComponentできる事に気づいた ので修正しました

shokai commented 9 years ago

jQuery.paramを使うとスペースが%20ではなく+になる事がわかりました 直します