Make WordPress Core

Opened 14 years ago

Closed 12 days ago

#18446 closed defect (bug) (wontfix)

Widget removes fields w/ default HTML on initial save in IE8 and 9

Reported by: layotte's profile layotte Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Widgets Keywords: dev-feedback has-patch
Focuses: Cc:

Description

Weird problem, testd in IE8/9, Chrome, and Firefox. If you have a widget, with HTML in the default value, IE8/9 will remove the field entirely. However, if you then paste the HTML back into the field and save, it works fine. This ONLY happens after the initial drag/drop then save of the widget. It even happens if you drag/drop the widget, change the field and click save.

Example Plugin: http://wordpress.org/extend/plugins/ft-calendar/
Widget: Upcoming Events Widget

The Event Template (event_template) is set by default to:

<a href="%URL">%TITLE%</a>

The event_template source for the Available Widget is:

<input type="text" value="&lt;a href=&quot;%URL%&quot;&gt;%TITLE% (%TIME%)&lt;/a&gt;" name="widget-ft_cal_event_list[__i__][event_template]" id="widget-ft_cal_event_list-__i__-event_template" class="widefat" />  


The event_template source for the widget after it is dragged to a widget area is:

<input type="text" value="&lt;a href=&quot;%URL%&quot;&gt;%TITLE% (%TIME%)&lt;/a&gt;" name="widget-ft_cal_event_list[8][event_template]" id="widget-ft_cal_event_list-8-event_template" class="widefat" /> 

The source for the widget after it is first saved is:

<input type="text" value="&lt;a href=&quot;%URL%&quot;&gt;%TITLE% (%TIME%)&lt;/a&gt;" name="widget-ft_cal_event_list[8][event_template]" id="widget-ft_cal_event_list-8-event_template" class="widefat" />

I setup a test to output $new_instance and $old_instance during the "update" process.

Step 1: Moving widget from Available Widgets to Widget Area (in IE):

NEW INSTANCE:
Array
(
    [title] =>
    [date] =>
    [number_of] => 1
    [date_types] => Month
    [limit] => 0
    [timeformat] => g:i a
    [dateformat] => jS
    [date_template] => %DATE%
    [monthformat] => F Y
    [month_template] => %MONTH%
)
OLD INSTANCE:
Array
(
)

Step 2: Saving widget in Widget Area:

NEW INSTANCE:
Array
(
    [title] =>
    [date] =>
    [number_of] => 1
    [date_types] => Month
    [limit] => 0
    [timeformat] => g:i a
    [dateformat] => jS
    [date_template] => %DATE%
    [monthformat] => F Y
    [month_template] => %MONTH%
)
OLD INSTANCE:
Array
(
    [title] =>
    [show_rss_feed] => off
    [show_ical_feed] => off
    [date] =>
    [span] => +1 Month
    [number_of] => 1
    [date_types] => Month
    [calendars] =>
    [limit] => 0
    [dateformat] => jS
    [timeformat] => g:i a
    [monthformat] => F Y
    [event_template] =>
    [date_template] => %DATE%
    [month_template] => %MONTH%
    [hide_duplicates] =>
)

Step 3: Pasting HTML code back into Event Template and saving Widget:

NEW INSTANCE:
Array
(
    [title] =>
    [date] =>
    [number_of] => 1
    [date_types] => Month
    [limit] => 0
    [timeformat] => g:i a
    [dateformat] => jS
    [date_template] => %DATE%
    [monthformat] => F Y
    [month_template] => %MONTH%
    [event_template] => <a href="%URL%">%TITLE% (%TIME%)</a>
)
OLD INSTANCE:
Array
(
    [title] =>
    [show_rss_feed] => off
    [show_ical_feed] => off
    [date] =>
    [span] => +1 Month
    [number_of] => 1
    [date_types] => Month
    [calendars] =>
    [limit] => 0
    [dateformat] => jS
    [timeformat] => g:i a
    [monthformat] => F Y
    [event_template] =>
    [date_template] => %DATE%
    [month_template] => %MONTH%
    [hide_duplicates] =>
)

Here is a screenr showing the problem not working in IE9 and working in Chrome: http://www.screenr.com/mkhs

Attachments (1)

18446.patch (646 bytes) - added by SergeyBiryukov 14 years ago.

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
14 years ago

  • Keywords has-patch added

Apparently IE uses unencoded values in DOM, in spite of esc_attr():

<INPUT value='<a href="%URL%">%TITLE% (%TIME%)</a>' ...

There's a regular expression in widgets.dev.js which replaces __i__ with a proper number:
http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/js/widgets.dev.js#L122

In IE, it fails on fields with HTML values, and they end up in a separate array on POST:

[widget-ft_cal_event_list] => Array
    (
        [5] => Array
            (
                [title] => 
                [calendars] => all
                [number_of] => 1
                [date_types] => Month
                [limit] => 0
                [timeformat] => H:i
                [dateformat] => jS
                [date_template] => %DATE%
                [monthformat] => F Y
                [month_template] => %MONTH%
            )

        [__i__] => Array
            (
                [event_template] => <a href="%URL">%TITLE% (%TIME%)/a>
            )

    )

18446.patch is an attempt to fix this.

Version 0, edited 14 years ago by SergeyBiryukov (next)

#2 @layotte
14 years ago

Good find! I'm surprised no one noticed this before.

Thanks.
Lew

#3 @SergeyBiryukov
12 years ago

#24493 was marked as a duplicate.

#4 @Frumph
12 years ago

#24493 has better information from nofearinc where it's coming from and what line is doing it

#5 @SergeyBiryukov
11 years ago

#30351 was marked as a duplicate.

#6 @callumbw95
12 days ago

  • Resolution set to wontfix
  • Status changed from new to closed

Hi All,
I have just been taking a look at this ticket, as well as the history around it, and a great deal has changed since this report was filed. The WordPress project no longer supports Internet Explorer, as the browser has been retired for many years. Additionally, the classic widget system is now in maintenance mode, with development focus having shifted entirely to block-based widgets.

Given the extreme age of this ticket, the fact that it pertains exclusively to unsupported browsers, and the evolution of the widget system, this issue is no longer relevant within the current state of WordPress.

For these reasons, I am closing this ticket as wontfix, but feel free to reopen the ticket if you have further comments. 😃

Note: See TracTickets for help on using tickets.