Opened 2 years ago

Closed 2 years ago

Last modified 2 years 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 by Mariusz Felisiak, 2 years ago

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 by David Wobrock, 2 years ago

Cc: David Wobrock added

in reply to:  1 comment:3 by Ankur Roy, 2 years ago

Yes, I would. Thank you.

comment:4 by Carlton Gibson, 2 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Mariusz Felisiak, 2 years ago

Easy pickings: set

comment:6 by Mariusz Felisiak, 2 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

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 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

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