Browse Source

Small security check for uploaded files.

Ralfp 12 years ago
parent
commit
6994274bc5
1 changed files with 6 additions and 0 deletions
  1. 6 0
      misago/urls.py

+ 6 - 0
misago/urls.py

@@ -48,3 +48,9 @@ if settings.DEBUG:
 # Set error handlers
 handler403 = 'misago.apps.errors.error403'
 handler404 = 'misago.apps.errors.error404'
+
+# Make sure people are not keeping uploads and app under same domain
+from django.core.exceptions import ImproperlyConfigured
+from urlparse import urlparse
+if not settings.DEBUG and not urlparse(settings.MEDIA_URL).netloc:
+    raise ImproperlyConfigured('Sharing same domain name between application and user uploaded media is a security risk. Create a subdomain pointing to your media directory (eg. "uploads.myforum.com") and change your MEDIA_URL.')