Make WordPress Core

Ticket #17004: 17004.2.diff

File 17004.2.diff, 6.8 KB (added by jacobwg, 14 years ago)

Patch to fix quoting of jQuery attribute selectors for the Display Name drop down in user profile

  • wp-admin/js/user-profile.dev.js

     
    2828                                $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
    2929                }
    3030        }
     31       
     32        function escape_selector(val) {
     33                return val.replace(/([\!\"\#\$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\[\\\]\^\`\{\|\}\~])/g, '\\$1');
     34        }
    3135
    3236        $(document).ready( function() {
    3337                $('#pass1').val('').keyup( check_pass_strength );
     
    3943                        var select = $('#display_name');
    4044                        var sel = select.children('option:selected').attr('id');
    4145                        select.children('#display_nickname').remove();
    42                         if ( ! select.children('option[value=' + str + ']').length )
     46                        if ( ! select.find('option[value="' + escape_selector(str) + '"]').length )
    4347                                select.append('<option id="display_nickname" value="' + str + '">' + str + '</option>');
    4448                        $('#'+sel).attr('selected', 'selected');
    4549                });
     
    4852                        var first = $('#first_name').val(), last = $('#last_name').val();
    4953                        var sel = select.children('option:selected').attr('id');
    5054                        $('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
    51                         if ( first && ! select.children('option[value=' + first + ']').length )
     55                        if ( first && ! select.find('option[value="' + escape_selector(first) + '"]').length )
    5256                                select.append('<option id="display_firstname" value="' + first + '">' + first + '</option>');
    53                         if ( last && ! select.children('option[value=' + last + ']').length )
     57                        if ( last && ! select.find('option[value="' + escape_selector(last) + '"]').length )
    5458                                select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
    5559                        if ( first && last ) {
    56                                 if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
     60                                if ( ! select.find('option[value="' + escape_selector(first + ' ' + last) + '"]').length )
    5761                                        select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>');
    58                                 if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
     62                                if ( ! select.find('option[value="' + escape_selector(last + ' ' + first) + '"]').length )
    5963                                        select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
    6064                        }
    6165                        $('#'+sel).attr('selected', 'selected');
  • wp-admin/js/user-profile.js

     
    1 (function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var e=a(this).val()||a("#user_login").val();var c=a("#display_name");var d=c.children("option:selected").attr("id");c.children("#display_nickname").remove();if(!c.children("option[value="+e+"]").length){c.append('<option id="display_nickname" value="'+e+'">'+e+"</option>")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('<option id="display_firstname" value="'+f+'">'+f+"</option>")}if(d&&!c.children("option[value="+d+"]").length){c.append('<option id="display_lastname" value="'+d+'">'+d+"</option>")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('<option id="display_firstlast" value="'+f+" "+d+'">'+f+" "+d+"</option>")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('<option id="display_lastfirst" value="'+d+" "+f+'">'+d+" "+f+"</option>")}}a("#"+e).attr("selected","selected")})})})(jQuery);
    2  No newline at end of file
     1(function(b){function c(){var f=b("#pass1").val(),e=b("#user_login").val(),d=b("#pass2").val(),g;b("#pass-strength-result").removeClass("short bad good strong");if(!f){b("#pass-strength-result").html(pwsL10n.empty);return}g=passwordStrength(f,e,d);switch(g){case 2:b("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:b("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:b("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:b("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:b("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}function a(d){return d.replace(/([\!\"\#\$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\[\\\]\^\`\{\|\}\~])/g,"\\$1")}b(document).ready(function(){b("#pass1").val("").keyup(c);b("#pass2").val("").keyup(c);b("#pass-strength-result").show();b(".color-palette").click(function(){b(this).siblings("input[name=admin_color]").attr("checked","checked")});b("#nickname").blur(function(){var f=b(this).val()||b("#user_login").val();var d=b("#display_name");var e=d.children("option:selected").attr("id");d.children("#display_nickname").remove();if(!d.find('option[value="'+a(f)+'"]').length){d.append('<option id="display_nickname" value="'+f+'">'+f+"</option>")}b("#"+e).attr("selected","selected")});b("#first_name, #last_name").blur(function(){var d=b("#display_name");var g=b("#first_name").val(),e=b("#last_name").val();var f=d.children("option:selected").attr("id");b("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(g&&!d.find('option[value="'+a(g)+'"]').length){d.append('<option id="display_firstname" value="'+g+'">'+g+"</option>")}if(e&&!d.find('option[value="'+a(e)+'"]').length){d.append('<option id="display_lastname" value="'+e+'">'+e+"</option>")}if(g&&e){if(!d.find('option[value="'+a(g+" "+e)+'"]').length){d.append('<option id="display_firstlast" value="'+g+" "+e+'">'+g+" "+e+"</option>")}if(!d.find('option[value="'+a(e+" "+g)+'"]').length){d.append('<option id="display_lastfirst" value="'+e+" "+g+'">'+e+" "+g+"</option>")}}b("#"+f).attr("selected","selected")})})})(jQuery);
     2 No newline at end of file