javascript - Solving bug with single quotes in names of friends -


My Javascript application uses Facebook Connect to display profile pictures of a user's friend.

This work is fine until a recent update at the end of Facebook created a bug in Safari.

Essentially, everything works fine until a user's friend does not have an apostrophe (single bid) in their name. For example, learn Irish last names such as oaknaur. An apostrophe breaks the rendering of all profile pictures completely, and instead silhouettes are displayed only.

Generally when FB: profile pictures, the friend's name becomes the value of the alt and title attributes of the image. However, with a name with an apostrophe, it is instead (using the name Gregory O'Connor for this example):

  & lt; Fb: profile-pic class = "FB_profile_pic_renderedFB_ElementReady" & gt; & Lt ;! - Funny new "connor" attribute notice - & gt; & Lt; Img class = "FB_profile_pic fb_profile_pic_rendered" style = "connor =" "title =" gregory o "alt =" gregory o "src =" http://profile.ak.fbcdn.net/path/to/friends/ profile / Image.jpg "& gt; & Lt; FB: Profile-pick & gt; Luckily for me, my code is similar to code, Facebook gives an example of the FB.APICLF.Andend_Get function, which can be found here (and if the safari bug is re- Will generate)  

  & lt; Div id = "profile_pics" & gt; & Lt; / Div & gt; There is an apostrophe in the name of a friend. & Lt; Script type = "text / javascript" & gt; Var widget_div = document.getElementById ("profiles_pix"); FB.ensureInit (function () {FB.Facebook.apiClient.friends_get} (blank, function (result) {var markup = ""; var num_friends = result? Math.min (10, result.length): 0; if (num_friends & Gt; 0) {for (var i = 0; i & lt; num_friends; i ++) {markup + = '& lt; fb: profile-picture size = "square" uid = "' + result [i] + '"Facebook-logo =" true ">" +' & lt; / fb: profile-photo & gt; ';}} widget_div.innerHTML = markup; FB.XFBML.host.parseDomElement (widget_div);} );}); & Lt; / Script & gt;  

Since Facebook has shut down on this bug, I need to come up with a fix on my end. I started attempts to uproot Apostrops (which was extremely fast due to the communication and intangible layers between Facebook and our applications), and decided that I should retreat and advice about solving this problem. Must demand

Many thanks in advance.

Edit

I want to make a real-world example of HTML-generated calls through Facebook. Basically, the above JavaScript will capture the User ID from the call for the above result, and that result will generate the HTML for the image.

I believe this bug will be corrected by avoiding the results from IMG Alt and IMG titles, but the question of how to gain access to it is still available to me.

Example:

Profile - Logo = "wrong" link = "wrong" UID = "6841956" size = "normal" & gt; & Lt; Img class = "FB_profile_pic fb_profile_pic_rendered" style = "opacity: 1;" Connor = "" title = "Colin O" alt = "Colin O" src = "http://profile.ak.fbcdn.net/v227/676/36/n6841956_271.jpg" & gt; & Lt; / FB: Profile-pick & gt;

Thanks again!

F3 is related to the answer, but instead of trying to convert the whole result into symbolic terms (See the following links for differences) Can you convert single quotes not only to sign (or remove)?

 Result [i] .replace (/ '/ g, "% 27") 

Alternatively, this rajx pattern should match all instances of the character. Like 'Robert', if you can provide an example of those who have returned, it will help a bunch. [']' / '[^'] * '' / '


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -