Browse Source

[Fix #19] use encodeURIComponent on api requests

B Thibault 8 years ago
parent
commit
02ac6fd588
2 changed files with 2 additions and 2 deletions
  1. 1 1
      cli/workflow.js
  2. 1 1
      srv/public/slack.min.js

+ 1 - 1
cli/workflow.js

@@ -101,7 +101,7 @@ function unselectRoom() {
 **/
 function sendMsg(chan, msg) {
     var xhr = new XMLHttpRequest();
-    xhr.open('POST', 'api/msg?room=' +chan.id +"&text=" +msg, true);
+    xhr.open('POST', 'api/msg?room=' +chan.id +"&text=" +encodeURIComponent(msg), true);
     xhr.send(null);
 }
 

+ 1 - 1
srv/public/slack.min.js

@@ -6,6 +6,6 @@ function z(a){var b=document.createElement("div"),e=document.createElement("div"
 l?l.name:a.raw.username||"?";d.src=l?l.b.i:"";f.appendChild(d);f.appendChild(k);b.appendChild(f);b.appendChild(c);b.appendChild(e);return b}function A(){var a=document.createDocumentFragment();document.getElementById("chatWindow").textContent="";y.b[B.id]&&y.b[B.id].a.forEach(function(b){a.appendChild(z(b))});document.getElementById("chatWindow").appendChild(a)}
 function C(a){for(;a.target!==a.currentTarget&&a.target;){if(a.target.classList.contains("slack-context-room")){if((a=y.a.f[a.target.id]||y.a.g[a.target.id]||y.a.b[a.target.id])&&a!==B){B&&document.getElementById(B.id).classList.remove("selected");document.getElementById(a.id).classList.add("selected");document.body.classList.remove("no-room-selected");B=a;a=void 0;var b=B.name||(B.c?B.c.name:void 0);if(!b){b=[];for(a in B.a)b.push(B.a[a].name);b=b.join(", ")}document.getElementById("currentRoomTitle").textContent=
 b;A();B.b&&!y.b[B.id]&&(a=new XMLHttpRequest,a.open("GET","api/hist?room="+B.id,!0),a.send(null))}break}a.target=a.target.parentElement}}
-document.addEventListener("DOMContentLoaded",function(){document.getElementById("chatList").addEventListener("click",C);document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");if(B&&a.value){var b=new XMLHttpRequest;b.open("POST","api/msg?room="+B.id+"&text="+a.value,!0);b.send(null);a.value=""}return!1});D()});var y;y=new function(){this.c=0;this.a=new t;this.b={}};var E=5,B=null;function F(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var e=null,c=2===Math.floor(b.status/100);if(c){E=5;e=b.response;try{e=JSON.parse(e)}catch(f){e=null}}else E+=Math.floor(E/2),E=Math.min(60,E);a(c,e)}else F(a),E=5};b.open("GET","api?v="+y.c,!0);b.send(null)}
+document.addEventListener("DOMContentLoaded",function(){document.getElementById("chatList").addEventListener("click",C);document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");if(B&&a.value){var b=new XMLHttpRequest;b.open("POST","api/msg?room="+B.id+"&text="+encodeURIComponent(a.value),!0);b.send(null);a.value=""}return!1});D()});var y;y=new function(){this.c=0;this.a=new t;this.b={}};var E=5,B=null;function F(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var e=null,c=2===Math.floor(b.status/100);if(c){E=5;e=b.response;try{e=JSON.parse(e)}catch(f){e=null}}else E+=Math.floor(E/2),E=Math.min(60,E);a(c,e)}else F(a),E=5};b.open("GET","api?v="+y.c,!0);b.send(null)}
 function G(a,b){if(a){if(b){var e=y;b.v&&(e.c=b.v);if(b["static"]){for(var c=e.a,f=b["static"],d=0,k=f.bots.length;d<k;d++)c.h[f.bots[d].id]=new r(f.bots[d]);d=0;for(k=f.users.length;d<k;d++)c.a[f.users[d].id]=new q(f.users[d]);d=0;for(k=f.ims.length;d<k;d++){var l=h(c,f.ims[d].user);l&&(l.a=new n(l,f.ims[d]),c.g[l.a.id]=l.a)}d=0;for(k=f.channels.length;d<k;d++)c.f[f.channels[d].id]=new g(f.channels[d],c);d=0;for(k=f.groups.length;d<k;d++)c.b[f.groups[d].id]=new m(c,f.groups[d]);c.c=h(c,f.self.id);
 x()}if(b.live){for(var p in b.live)(c=e.b[p])?w(c,b.live[p]):e.b[p]=new v(p,500,b.live[p]);B&&b.live[B.id]&&A()}}D()}else setTimeout(D,1E3*E)}function D(){F(G)};