[Techtalk] help debugging some JS

Carla Schroder carla at bratgrrl.com
Wed Jun 12 21:27:43 UTC 2013


hey all,

I have a weird Javascript problem that is defying my feeble JS skills
to resolve. One of the sites I herd, socialmediatoday.com, uses the
Gigya social login and sharing widget. The problem is the Twitter
sharing widget doesn't handle ampersands in article titles correctly,
so this

Social Advocacy & Politics: All Secrecy and No Privacy in the
Surveillance Society

becomes this:


Social Advocacy & Politics: All Secrecy and No Privacy in the
Surveillance Society 

You can try this for yourself at
https://socialmediatoday.com/drdigipol/1526916/social-advocacy-politics-all-secrecy-and-no-privacy-surveillance-society

The odd thing is the Facebook sharing widget doesn't do this, but
passes on the article title correctly, with the ampersand instead of
&

I asked the nice Gigya people about it, and this what they said:

"The title on the page doesn't matter because in their javascript you
are passing Gigya a UserAction object: 

<script type="text/javascript">
var act = new gigya.services.socialize.UserAction();
act.setUserMessage("Shared an article");
act.setTitle("Social Advocacy & Politics: A Virtual Political
Debate Via Twitter"); "

Which you can see in the page source.


I'm not sure where to go at this point. I've poked around in the site
files and I found these files in /var/www/docroot/js/:

js_2750b5c86ca732ce9663c74185205ac6.js
js_675a00f3cc4c25a1e21e3e8ec43ac1ed.js
js_38e71c6938f16552c9e288fe9f10a260.js
js_6d3e78a8987179c8716199764d4aa9d3.js
js_5920d09a2db1ba8a3f7c3683abfbe4ce.js
js_c25c0f789b27908c76ba84bf18ac3cd8.js

They're all similar, and they contain lines like this for handling
punctuation:

Drupal.gigya.getHTMLEncode  = function (t) {
  return t.toString().replace(/&/g, "&").replace(/"/g,
""").replace(/</g, "<").replace(/>/g, ">"); }


Drupal.checkPlain = function(str) {
  str = String(str);
  var replace = { '&': '&', '"': '"', '<': '<', '>':
'>' }; for (var character in replace) {
    var regex = new RegExp(character, 'g');
    str = str.replace(regex, replace[character]);
  }
  return str;
};

To my inexperienced eye those look like they should handle this sort of
thing the correct way. And I haven't found anything that looks like it
would handle the Twitter widget differently than the Facebook widget. So
what do I do now?

thanks!

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Carla Schroder
ace Linux nerd
buy my books! Book of Audacity,
Linux Networking Cookbook,
Linux Cookbook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


More information about the Techtalk mailing list