Make WordPress Core

Changeset 8385


Ignore:
Timestamp:
07/21/2008 01:15:49 AM (17 years ago)
Author:
azaozz
Message:

Take first attribute and ignore later duplicate attributes. Fixes #6602 for 2.6.1. Props schiller.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/wp-includes/kses.php

    r8383 r8385  
    538538 * or apostrophes around them, to make it easier to produce HTML code that will
    539539 * conform to W3C's HTML specification. It will also remove bad URL protocols
    540  * from attribute values.
     540 * from attribute values.  It also reduces duplicate attributes by using the
     541 * attribute defined first (foo='bar' foo='baz' will result in foo='bar').
    541542 *
    542543 * @since 1.0.0
     
    581582                    $working = 1;
    582583                    $mode = 0;
    583                     $attrarr[] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
     584                    if(FALSE === array_key_exists($attrname, $attrarr)) {
     585                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
     586                    }
    584587                    $attr = preg_replace('/^\s+/', '', $attr);
    585588                }
     
    594597                    $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
    595598
    596                     $attrarr[] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
     599                    if(FALSE === array_key_exists($attrname, $attrarr)) {
     600                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
     601                    }
    597602                    $working = 1;
    598603                    $mode = 0;
     
    606611                    $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
    607612
    608                     $attrarr[] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
     613                    if(FALSE === array_key_exists($attrname, $attrarr)) {
     614                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
     615                    }
    609616                    $working = 1;
    610617                    $mode = 0;
     
    618625                    $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
    619626
    620                     $attrarr[] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
     627                    if(FALSE === array_key_exists($attrname, $attrarr)) {
     628                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
     629                    }
    621630                    # We add quotes to conform to W3C's HTML spec.
    622631                    $working = 1;
     
    635644    } # while
    636645
    637     if ($mode == 1)
     646    if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr))
    638647        # special case, for when the attribute list ends with a valueless
    639648        # attribute like "selected"
    640         $attrarr[] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
     649        $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
    641650
    642651    return $attrarr;
Note: See TracChangeset for help on using the changeset viewer.