Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#8885 closed (fixed)

HTML markup appearing in title of doc page

Reported by: gkelly Owned by: nobody
Component: *.djangoproject.com Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

The page at http://docs.djangoproject.com/en/dev/ref/models/options/ has HTML markup appearing in the title for the page. I haven't seen this with other pages, but it's possible this isn't the only affected URL.

Attachments (1)

8885-1.diff (785 bytes) - added by gkelly 8 years ago.
Fixes title, but removes other markup

Download all attachments as: .zip

Change History (16)

comment:1 Changed 8 years ago by gkelly

Changed 8 years ago by gkelly

Attachment: 8885-1.diff added

Fixes title, but removes other markup

comment:2 Changed 8 years ago by gkelly

Please ignore patch, a better solution would be to use a template filter to strip the HTML from the title, such as

Index: djangodocs/templates/docs/doc.html
===================================================================
--- djangodocs/templates/docs/doc.html	(revision 8965)
+++ djangodocs/templates/docs/doc.html	(working copy)
@@ -1,6 +1,6 @@
 {% extends "base_docs.html" %}
 
-{% block title %}{{ doc.title }} | Django Documentation{% endblock %}
+{% block title %}{{ doc.title|striptags }} | Django Documentation{% endblock %}
 
 {% block extrahead %}
   {{ block.super }}

comment:3 Changed 8 years ago by arien

Component: DocumentationDjango Web site
Has patch: set

Changing component; locally generated HTML (make html) doesn't have this problem.

comment:4 Changed 8 years ago by Carl Meyer

comment:5 Changed 8 years ago by Julien Phalip

http://docs.djangoproject.com/en/dev/ref/contrib/comments/ also suffers from this strange disease :)

comment:6 Changed 8 years ago by Julien Phalip

Triage Stage: UnreviewedAccepted

comment:7 Changed 8 years ago by Chris Beaven

See also for another semi-related problem: #9517 (titles show up escaped in Browse section of the sidebar)

comment:9 Changed 8 years ago by Ramiro Morales

#9647 was also a duplicate, and it suggested:

Maybe a |safe filter is needed to be appended to the title tag to allow these characters to be unescaped? 

comment:10 Changed 8 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

#10495 reported this again and also suggested a striptags filter on the title tag.

comment:11 Changed 8 years ago by Karen Tracey

Resolution: duplicate
Status: closedreopened

Meant to close the other one, not this one.

comment:12 Changed 7 years ago by anonymous

This is still occurring, nearly 11 months after first being opened :)

comment:13 Changed 7 years ago by Chris Beaven

Patch needs improvement: set

#11839 suggests striptags filter too, and has a patch. Modifying documentation to work around the current problem isn't the solution, so I'm marking the patch here as "needs improvement".

comment:14 Changed 7 years ago by James Bennett

Resolution: fixed
Status: reopenedclosed

(In [11598]) Fixed #8885 and its many duplicates (hopefully) by stripping HTML (which implies mark_safe) to titles of documentation pages.

comment:15 in reply to:  14 Changed 7 years ago by Karen Tracey

Replying to ubernostrum:

(In [11598]) Fixed #8885 and its many duplicates (hopefully) by stripping HTML (which implies mark_safe) to titles of documentation pages.

striptags has is_safe=True but that won't explicitly mark the output as safe, it will just preserve the safe status of input. We don't mark the title as safe, so it is still being escaped, which means titles with smart quotes, such as:

http://docs.djangoproject.com/en/dev/ref/contrib/sites/
http://docs.djangoproject.com/en/dev/ref/contrib/comments/
http://docs.djangoproject.com/en/dev/internals/release-process/
http://docs.djangoproject.com/en/dev/topics/cache/

are still looking a bit odd. Could we also just explicitly run doc.title through the safe filter?

Note: See TracTickets for help on using tickets.
Back to Top