Possible Bug: Your caching of callbacks needs to be case sensitive

fraser.iain May 09, 2012 12:04AM EDT

Hello there

I am having an issue with your widget script that I find causes a javascript error under certain circumstances. I have done some trouble-shooting and can give you steps to reproduce (below).

I find that on pageload addthis_widget.js makes a call to http://api-public.addthis.com/url/shares.json and sets the callback function-name as an abbreviated version of the URL the user is currently on.

If the website your widget is installed on supports case-insensitive URLs, addthis_widget.js asks for the correct callback, but shares.json doesn't necessarily attempt to call the correct function if the page has been loaded once before using different casing.

Steps to reproduce
---------------------
1. Install the widget on a website, as per the instructions on your front page

2. Visit a page on that website (http://www.example.com/MyGreatPage)

3. Note that everything seems to work fine

- addthis_widget.js requests the following:
http://api-public.addthis.com/url/shares.json?url=http%3A%2F%2Fwww.example.com%2FMyGreatPage&callback=_ate.cbs.sc_httpwwwexamplecomMyGreatPage0

- The request loads up and calls the following function:
_ate.cbs.sc_httpwwwexamplecomMyGreatPage0()

4. Now type the same address into your browser in lowercase (http://www.example.com/mygreatpage)

5. Note a javascript error:

- _ate.cbs.sc_httpwwwexamplecomMyGreatPage0 is not a function

6. Take a look at the request:

- http://api-public.addthis.com/url/shares.json?url=http%3A%2F%2Fwww.example.com%2Fmygreatpage&callback=_ate.cbs.sc_httpwwwexamplecommygreatpage0

- Pay particular attention to the requested callback:
_ate.cbs.sc_httpwwwexamplecommygreatpage0

7. Take a look at the callback that is returned from shares.json:
- _ate.cbs.sc_httpwwwexamplecomMyGreatPage0

8. Compare side-by-side:
Requested: _ate.cbs.sc_httpwwwexamplecommygreatpage0
Received : _ate.cbs.sc_httpwwwexamplecomMyGreatPage0

---------

I am just guessing, but I presume some kind of caching is going on in your application. The part of the application that checks the cache for existing callbacks seems to be ignoring the case of those callbacks - meaning that it might return a callback in the incorrect case, which will cause a javascript error on client machines.

Kind regards
Iain Fraser

Up 0 Rated Down
Paul (AddThis Happiness Specialist) May 09, 2012 11:34AM EDT
Thanks for pointing out this bug and for the step-by-step instructions on reproducing it. I've let our developers know and we'll get it fixed as soon as possible.

This question is closed to new answers.

Still need help?


General Topics

 

Developers