Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#33784 closed Bug (fixed)

Formats should not be escaped in admin calendar widget.

Reported by: Mariusz Felisiak Owned by: Ankur Roy
Component: contrib.admin Version: 4.0
Severity: Normal Keywords:
Cc: Ankur Roy, David Wobrock Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Replacements were added in fa0653cd1d791a8bce835e8992cbeab6fd70d0e7 where we created a callback function by concatenating strings. It's unnecessary and buggy since d638cdc42acec608c1967f44af6be32a477c239f.

Change History (8)

comment:1 Changed 4 months ago by Mariusz Felisiak

Ankur, would you like to prepare a patch? and drop these replacements, e.g.

  • django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js

    diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
    index ea8c155d74..aa1cae9eeb 100644
    a b  
    387387            DateTimeShortcuts.calendars[num].drawNextMonth();
    388388        },
    389389        handleCalendarCallback: function(num) {
    390             let format = get_format('DATE_INPUT_FORMATS')[0];
    391             // the format needs to be escaped a little
    392             format = format.replace('\\', '\\\\')
    393                 .replace('\r', '\\r')
    394                 .replace('\n', '\\n')
    395                 .replace('\t', '\\t')
    396                 .replace("'", "\\'");
     390            const format = get_format('DATE_INPUT_FORMATS')[0];
    397391            return function(y, m, d) {
    398392                DateTimeShortcuts.calendarInputs[num].value = new Date(y, m - 1, d).strftime(format);
    399393                DateTimeShortcuts.calendarInputs[num].focus()

comment:2 Changed 4 months ago by David Wobrock

Cc: David Wobrock added

comment:3 in reply to:  1 Changed 4 months ago by Ankur Roy

Yes, I would. Thank you.

comment:4 Changed 4 months ago by Carlton Gibson

Triage Stage: UnreviewedAccepted

comment:5 Changed 4 months ago by Mariusz Felisiak

Easy pickings: set

comment:6 Changed 4 months ago by Mariusz Felisiak

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:7 Changed 4 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In d19a53d8:

Fixed #33784 -- Removed unnecessary format escaping in admin calendar widget.

Replacements were added in fa0653cd1d791a8bce835e8992cbeab6fd70d0e7
where we created a callback function by concatenating strings. It's
unnecessary since d638cdc42acec608c1967f44af6be32a477c239f.

comment:8 Changed 4 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 5197014:

[4.1.x] Fixed #33784 -- Removed unnecessary format escaping in admin calendar widget.

Replacements were added in fa0653cd1d791a8bce835e8992cbeab6fd70d0e7
where we created a callback function by concatenating strings. It's
unnecessary since d638cdc42acec608c1967f44af6be32a477c239f.

Backport of d19a53d8e3640e8f937048bf7826c7e2229a9665 from main

Note: See TracTickets for help on using tickets.
Back to Top