I'm injecting a script via JSONP and using it to call a method in my web application like so:
(function jsonp(src){
var b = document.body;
var t = document.title;
var u = encodeURI(document.location.href);
var o = document.getElementById('srv-call');
o && b.removeChild(o);
var s = document.createElement('script');
s.id = 'srv-call';
s.src = src + '?w=' + textSelection + '&cb=autoCall&u=' + u + '&pt=' + t + '&t=' + (new Date().getTime());
b.appendChild(s);
})('http://localhost:8888/wordmark/words/add_word');
Unfortunately, my document.title is getting filled with non-breaking spaces. An example http request is this:
http://localhost:8888/wordmark/words/add_word?w=problems&cb=autoCall&u=http://www.boingboing.net/2010/10/01/kid-demonstrates-eng.html&pt=%E2%80%8BK%E2%80%8Bi%E2%80%8Bd%E2%80%8B%20%E2%80%8Bd%E2%80%8Be%E2%80%8Bm%E2%80%8Bo%E2%80%8Bn%E2%80%8Bs%E2%80%8Bt%E2%80%8Br%E2%80%8Ba%E2%80%8Bt%E2%80%8Be%E2%80%8Bs%E2%80%8B%20%E2%80%8BE%E2%80%8Bn%E2%80%8Bg%E2%80%8Bl%E2%80%8Bi%E2%80%8Bs%E2%80%8Bh%E2%80%8B%20%E2%80%8Bl%E2%80%8Ba%E2%80%8Bn%E2%80%8Bg%E2%80%8Bu%E2%80%8Ba%E2%80%8Bg%E2%80%8Be%E2%80%8B%20%E2%80%8Bi%E2%80%8Bn%E2%80%8B%20%E2%80%8B2%E2%80%8B4%E2%80%8B%20%E2%80%8Ba%E2%80%8Bc%E2%80%8Bc%E2%80%8Be%E2%80%8Bn%E2%80%8Bt%E2%80%8Bs%E2%80%8B%20%E2%80%8B-%E2%80%8B%20%E2%80%8BB%E2%80%8Bo%E2%80%8Bi%E2%80%8Bn%E2%80%8Bg%E2%80%8B%20%E2%80%8BB%E2%80%8Bo%E2%80%8Bi%E2%80%8Bn%E2%80%8Bg&t=1285982312594
The script that is injected in the page has the correct src, but the HTTP request is incorrect. Any idea why these are being inserted and if I have any way to avoid this, other than parsing them out via regex?
Thanks so much for any help you can give.