Opened 3 years ago
Last modified 2 years ago
#33589 closed Bug
Incomplete string escaping in formats for calendar. — at Version 2
Reported by: | Shrikant Dhayje | Owned by: | Shrikant Dhayje |
---|---|---|---|
Component: | contrib.admin | Version: | 4.0 |
Severity: | Normal | Keywords: | bug, regex, Inaccurate |
Cc: | David Wobrock, Sander Beekhuis | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
At
The Given Code
390| handleCalendarCallback: function(num) { 391| let format = get_format('DATE_INPUT_FORMATS')[0]; 392| // the format needs to be escaped a little 393| format = format.replace('\\', '\\\\') 394| .replace('\r', '\\r') 395| .replace('\n', '\\n') 396| .replace('\t', '\\t')
This replaces only the first occurrence of all the escape characters not all, and as per the the function is unable to completely accurate replacement of string with escape characters.
This replaces only the first occurrence of "", "/r", "/n", "/t" and "'",
So We Should Use regex for replacing all occurrence.
Used regex for easy updating.
This issue "Has patch" https://github.com/django/django/pull/15460
Change History (2)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
Cc: | removed |
---|---|
Description: | modified (diff) |
Needs tests: | set |
Owner: | changed from | to
Status: | new → assigned |
Summary: | Incomplete string escaping or encoding → Incomplete string escaping in formats for calendar. |
Triage Stage: | Unreviewed → Accepted |
Seems reasonable. Can you add a regression test? Do you have an example of the format with multiple occurrence of the same char that should be escaped?
"Has patch" https://github.com/django/django/pull/15460