[Techtalk] help debugging some JS
Kagan MacTane
kagan at mactane.org
Thu Jun 13 02:46:57 UTC 2013
On 6/12/2013 2:27 PM, Carla Schroder wrote:
>
> 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.
Yup. Which means, the page source is passing a string containing '&'
to the gigya UserAction object. Try changing it to just 'Advocacy &
Politics' in that line in the page source, and it should be okay.
> 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.
Depends on what you mean by "the correct way". Both of those will
convert just plain '&' into '&', *not* the other way around.
--
Kagan ("Kai") MacTane
LAMP and AJAX web developer
http://kagan.mactane.org
More information about the Techtalk
mailing list