Opened 8 years ago

Closed 6 years ago

#9211 closed (duplicate)

Objects with newlines in representation break popup JavaScript in the admin

Reported by: jbronn Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords: admin popup newline carriage
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


When you have these models:

class Note(models.Model):
    text = models.TextField()

    def __unicode__(self):
        return self.text

class Person(models.Model):
    name = models.CharField(max_length=25)
    note = models.ForeignKey(Note)

    def __unicode__(self):

And the following in

from django.contrib import admin
from models import Note, Person

When entering a Person model in the admin a new may Note created by clicking the plus icon next to the selection list. If the person entering the note presses return and puts newlines in the TextField, the dismissAddAnotherPopup JavaScript chokes on the Notes representation.

Attached is a patch that escapes carriage returns, however, I want some discussion on whether there needs to be any other escaping performed.

Attachments (1)

admin_escape_popup_newlines.diff (811 bytes) - added by jbronn 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by jbronn

comment:1 Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Should this be done with escapejs() instead? That would handle the cases you've identified and a few dozen others as well. At first glance, it looks like the right tool here, but I might be missing something.

comment:2 Changed 8 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 6 years ago by ramiro

Duplicate of #2986.

comment:4 Changed 6 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top