The beauty One of C++’s problems is that there is no built in
string type. Even if you’re very comfortable with one type of string you’re completely unprepared for the next.
I was writing a part of a Firefox plugin that clears the browser’s cookies, looking at the header file I saw this:
NS_IMETHOD GetPath(nsACString & aPath) = 0;
Well I thought to myself naïvely, I guess I’ll have to use a variable of type
nsAString. But first I have to create a cookie manager, what should I name it?
The answer was obvious.
nsCOMPtr<nsICookieManager> cookieMonster; servMgr->GetServiceByContractID("@mozilla.org/cookiemanager;1", NS_GET_IID(nsICookieManager), getter_AddRefs(cookieMonster));
When I tried to get a cookie’s path I crashed, well it was time to go home so I decided to give it another shot the next day.
On the morrow I figured out that I needed to use a variable of type
nsEmbedCString and not
nsAstring (who knew?). <edit> Apparently pippy from reddit knew, this has got something to do with the fact that the plugin in question is in fact an extension not a plugin, why this should matter is beyond me</edit>
nsEmbedCString name; cookie->GetName(name); nsEmbedCString path; cookie->GetPath(path); spCookieMonster->Remove(host, name, path, PR_FALSE);
Now to check the damn thing works.
Those of you out of the US know that if you go to www.google.com it will take you to your country’s Google, this is a bit of a pain in Israel since the whole right to left thing tends to mess thing up. Luckily Google supplies the No Country Redirect option which sets a cookie telling Google to give you the international site. Little did I know that there’s another difference, NCR doesn’t (or didn’t) display doodles.
Imagine my surprise when after using my cookie monster to clear cookies, refreshing Google.com displayed this:
I mean it’s bad enough Google knows what searches I made, decompiling a plugin and commenting on my variable name selection is going too far!
P.S. The reason I mentioned that I was foiled by
nsAstring is to prove that I didn’t see the doodle and subconsciously name the variable accordingly, I named the variable the day before the doodle went live.
P.P.S. The events described above happened on the day my wife and I celebrated out bronze wedding anniversary and is scheduled to be published on our pottery anniversary, congrats us :).