Commit d6b5db4a authored by Skia's avatar Skia

Sanitize page name

parent 4d6c4314
......@@ -732,7 +732,15 @@ class Page(models.Model):
Be careful with the _full_name attribute: this field may not be valid until you call save(). It's made for fast
query, but don't rely on it when playing with a Page object, use get_full_name() instead!
"""
name = models.CharField(_('page name'), max_length=30, blank=False)
name = models.CharField(_('page unix name'), max_length=30,
validators=[
validators.RegexValidator(
r'^[\w.+-]+$',
_('Enter a valid page name. This value may contain only '
'letters, numbers ' 'and ./+/-/_ characters.')
),
],
blank=False)
parent = models.ForeignKey('self', related_name="children", verbose_name=_("parent"), null=True, blank=True, on_delete=models.SET_NULL)
# Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when
# playing with a Page object, use get_full_name() instead!
......
......@@ -9,7 +9,7 @@
<h3>{% trans %}Page list{% endtrans %}</h3>
<ul>
{% for p in page_list %}
<li><a href="{{ url('core:page', page_name=p.get_full_name()) }}">{{ p.get_display_name() }}</a></li>
<li><a href="{{ p.get_absolute_url() }}">{{ p.get_display_name() }}</a></li>
{% endfor %}
</ul>
{% else %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment