Skip to content

Commit 7dde59f

Browse files
committed
Avoid multiple doctype declarations and other html errors by parsing sesion agenda html files and inserting our title and doctype.
- Legacy-Id: 11417
1 parent 252c201 commit 7dde59f

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

ietf/meeting/views.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import csv
1111
import json
1212
import pytz
13+
from pyquery import PyQuery
1314

1415
import debug # pyflakes:ignore
1516

@@ -592,11 +593,22 @@ def session_agenda(request, num, session):
592593
return HttpResponse(content, content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
593594
elif ext == "pdf":
594595
return HttpResponse(content, content_type="application/pdf")
596+
elif ext in ["html", "htm"]:
597+
d = PyQuery(content)
598+
d("head title").empty()
599+
d("head title").append(str(agenda))
600+
d('meta[http-equiv]').remove()
601+
content = "<!doctype html>" + d.html()
602+
elif not content:
603+
content = "<p>Could not read agenda file '%s'</p>" % agenda.external_url
604+
content = (html5_preamble % agenda) + content + html5_postamble
605+
agenda = "Error"
595606
else:
596-
if not content:
597-
content = "<p>Could not read agenda file '%s'</p>" % agenda.external_url
598-
agenda = "Error"
599-
return HttpResponse((html5_preamble % agenda) + content + html5_postamble)
607+
content = "<p>Unrecognized agend file '%s'</p>" % agenda.external_url
608+
content = (html5_preamble % agenda) + content + html5_postamble
609+
agenda = "Error"
610+
611+
return HttpResponse(content)
600612

601613
raise Http404("No agenda for the %s session of IETF %s is available" % (session, num))
602614

0 commit comments

Comments
 (0)