Opened 16 years ago

Closed 14 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: no UI/UX: no

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 16 years ago.

Download all attachments as: .zip

Change History (5)

by jbronn, 16 years ago

comment:1 by Malcolm Tredinnick, 16 years ago

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 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 by Ramiro Morales, 14 years ago

Duplicate of #2986.

comment:4 by Ramiro Morales, 14 years ago

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