Skip to content

Commit f2a45f9

Browse files
committed
Fixed #4862 -- Fixed invalid Javascript creation in popup windows in admin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5694 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 501448e commit f2a45f9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

django/contrib/admin/templatetags/admin_list.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,11 @@ def items_for_result(cl, result):
190190
table_tag = {True:'th', False:'td'}[first]
191191
first = False
192192
url = cl.url_for_result(result)
193-
result_id = smart_unicode(getattr(result, pk)) # conversion to string is needed in case of 23L (long ints)
193+
# Convert the pk to something that can be used in Javascript.
194+
# Problem cases are long ints (23L) and non-ASCII strings.
195+
result_id = repr(force_unicode(getattr(result, pk)))[1:]
194196
yield (u'<%s%s><a href="%s"%s>%s</a></%s>' % \
195-
(table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr, table_tag))
197+
(table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), result_repr, table_tag))
196198
else:
197199
yield (u'<td%s>%s</td>' % (row_class, result_repr))
198200

0 commit comments

Comments
 (0)