On our site, we use google analytics and we have to put the GA cookie in the URL since we have a two letter domain and IE imposes some cookie limitations on those. This means that when going between subdomains we get these long URLs with the cookie string appended after a hash:
http://test.ab.la#_utma=what_have_you&_utmc=something_else&so=on&so=on
So, I added this code:
(* Remove fragment (the part after #) from URL if it contains a Google Analytics cookie.
We do this to hide the extremely long URLs that otherwise will be visible to the users.
Will not work in IE and other browsers that do not support history.replaceState().
Use GA's push functionality to do this to make sure the page has been tracked before
removing cookie information.*)
_gaq.push(function() {
if (window.history &&
window.history.replaceState &&
location.href.indexOf("__utma") > 0) {
window.history.replaceState({}, "", document.location.href.split("#")[0]);
}
});
After watching a talk at Jfokus by John Wilander where he mentioned a specific Twitter security issue, I got a little nervous.
My question is: Would my little hack above introduce any security holes, XSS or others? I don't think so, but I guess you've heard that before.
Update:
Maybe I should clarify my maybe somewhat unclear question: I did suspect that I wasn't having the exact same security problem as the Twitter one, but I since I am doing similar things I am wondering if there are any other vulnerabilities in my code?