From 3cd9bdf800d2ad2031c82ef14344740f12cb5ccc Mon Sep 17 00:00:00 2001
From: Christos Trochalakis <yatiohi@ideopolis.gr>
Date: Mon, 14 Jan 2008 19:37:42 +0200
Subject: [PATCH] contrib.flatpages: URL can now contain tilde

---
 django/contrib/flatpages/models.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
index 36327c8..f41d753 100644
--- a/django/contrib/flatpages/models.py
+++ b/django/contrib/flatpages/models.py
@@ -1,10 +1,19 @@
+import re
+
 from django.core import validators
 from django.db import models
 from django.contrib.sites.models import Site
 from django.utils.translation import ugettext_lazy as _
+from django.core.validators import ValidationError
+
+validURL_re = re.compile(r'^[-\w/~]+$')
+
+def isValidURL(field_data, all_data):
+    if not validURL_re.search(field_data):
+        raise ValidationError, _("This value must contain only letters, numbers, underscores, dashes, the tilde, or slashes.")
 
 class FlatPage(models.Model):
-    url = models.CharField(_('URL'), max_length=100, validator_list=[validators.isAlphaNumericURL], db_index=True,
+    url = models.CharField(_('URL'), max_length=100, validator_list=[isValidURL], db_index=True,
         help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."))
     title = models.CharField(_('title'), max_length=200)
     content = models.TextField(_('content'))
-- 
1.5.4.1

