Updated PLAN

- Legacy-Id: 14708
This commit is contained in:
Henrik Levkowetz 2018-02-27 17:55:43 +00:00
parent 9a456b8b52
commit a5db4d00de
5 changed files with 56 additions and 12 deletions

2
PLAN
View file

@ -7,8 +7,6 @@ Updated: $Date$
Planned work in rough order
===========================
* Upgrade Django to version 1.11
* Revisit the review tool, work through the accumulated tickets.
* Add sanitization of uploaded html documents.

View file

@ -613,9 +613,6 @@ CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'OPTIONS': {
'MAX_ENTRIES': 10000, # 10,000
},
},
'htmlized': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',

View file

@ -1,6 +1,7 @@
{% spaceless %}
{% autoescape off %}
{% load ietf_filters %}
{% load textfilters %}
{% if doc.get_state_slug == "rfc" %}
{% if doc.stream|slugify == "legacy" %}
@ -24,13 +25,14 @@
publisher = {% templatetag openbrace %}Internet Engineering Task Force{% templatetag closebrace %},
note = {% templatetag openbrace %}Work in Progress{% templatetag closebrace %},
url = {% templatetag openbrace %}https://datatracker.ietf.org/doc/html/{{doc.name}}-{{doc.rev}}{% templatetag closebrace %},{% endif %}
author = {% templatetag openbrace %}{% for author in doc.documentauthor_set.all %}{{ author.person.name}}{% if not forloop.last %} and {% endif %}{% endfor %}{% templatetag closebrace %},
title = {% templatetag openbrace %}{% templatetag openbrace %}{{doc.title}}{% templatetag closebrace %}{% templatetag closebrace %},
author = {% templatetag openbrace %}{% for author in doc.documentauthor_set.all %}{{ author.person.name|texescape}}{% if not forloop.last %} and {% endif %}{% endfor %}{% templatetag closebrace %},
title = {% templatetag openbrace %}{% templatetag openbrace %}{{doc.title|texescape}}{% templatetag closebrace %}{% templatetag closebrace %},
pagetotal = {{ doc.pages }},
year = {{ doc.pub_date.year }},
month = {{ doc.pub_date|date:"b" }},{% if not doc.rfc_number or doc.pub_date.day == 1 and doc.pub_date.month == 4 %}
day = {{ doc.pub_date.day }},{% endif %}
abstract = {% templatetag openbrace %}{{ doc.abstract|clean_whitespace }}{% templatetag closebrace %},
abstract = {% templatetag openbrace %}{{ doc.abstract|clean_whitespace|texescape }}{% templatetag closebrace %},
{% templatetag closebrace %}
{% endautoescape %}
{% endspaceless %}

View file

@ -1,11 +1,13 @@
from __future__ import unicode_literals
from django.template.library import Library
from django import template
from django.template.defaultfilters import stringfilter
from ietf.utils.text import xslugify as _xslugify
import debug # pyflakes:ignore
register = Library()
from ietf.utils.text import xslugify as _xslugify, texescape
register = template.Library()
@register.filter(is_safe=True)
@stringfilter
@ -26,3 +28,40 @@ def format(format, values):
tmp[f.name] = getattr(values, f.name)
values = tmp
return format.format(**values)
# ----------------------------------------------------------------------
# from django.utils.safestring import mark_safe
# class TeXEscapeNode(template.Node):
# """TeX escaping, rather than html escaping.
#
# Mostly, this tag is _not_ the right thing to use in a template that produces TeX
# markup, as it will escape all the markup characters, which is not what you want.
# Use the '|texescape' filter instead on text fragments where escaping is needed
# """
# def __init__(self, nodelist):
# self.nodelist = nodelist
#
# def render(self, context):
# saved_autoescape = context.autoescape
# context.autoescape = False
# text = self.nodelist.render(context)
# text = texescape(text)
# context.autoescape = saved_autoescape
# return mark_safe(text)
#
# @register.tag('texescape')
# def do_texescape(parser, token):
# args = token.contents.split()
# if len(args) != 1:
# raise TemplateSyntaxError("'texescape' tag takes no arguments.")
# nodelist = parser.parse(('endtexescape',))
# parser.delete_first_token()
# return TeXEscapeNode(nodelist)
@register.filter('texescape')
@stringfilter
def texescape_filter(value):
"A TeX escape filter"
return texescape(value)

View file

@ -11,6 +11,8 @@ from django.utils.safestring import mark_safe
import debug # pyflakes:ignore
from texescape import init as texescape_init, tex_escape_map
@keep_lazy(six.text_type)
def xslugify(value):
"""
@ -174,3 +176,9 @@ def dict_to_text(d):
for k, v in d.items():
t += "%s: %s\n" % (k, v)
return t
def texescape(s):
if not tex_escape_map:
texescape_init()
t = s.translate(tex_escape_map)
return t