#33589: Incomplete string escaping in formats for calendar.
-------------------------------------+-------------------------------------
     Reporter:  Shrikant Dhayje      |                    Owner:  Shrikant
                                     |  Dhayje
         Type:  Bug                  |                   Status:  assigned
    Component:  contrib.admin        |                  Version:  4.0
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
  bug,regex,Inaccurate               |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => assigned
 * cc: Has, patch, https://github.com/django/django/pull/15460 (removed)
 * needs_tests:  0 => 1
 * owner:  nobody => Shrikant Dhayje
 * stage:  Unreviewed => Accepted


Old description:

> 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

New description:

 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

--

Comment:

 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?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33589#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fab130d7b-c664417a-642b-4259-94c9-0c6ff2362e51-000000%40eu-central-1.amazonses.com.

Reply via email to