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:

Description

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):
        return self.name

And the following in admin.py:

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

admin.site.register(Note)
admin.site.register(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 Malcolm Tredinnick

Triage Stage: UnreviewedAccepted

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 (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 Changed 6 years ago by Ramiro Morales

Duplicate of #2986.

comment:4 Changed 6 years ago by Ramiro Morales

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top