Commits

Stanislav Panasik committed 79651ad

added PYBB_ALLOW_RELATIVE_URLS setting to allow relative urls used in the forum posts if enabled

  • Participants
  • Parent commits 3593919

Comments (0)

Files changed (2)

File pybb/markups/postmarkup.py

 import re
 from urllib import quote, unquote, quote_plus
 from urlparse import urlparse, urlunparse
+from django.conf import settings
 
 pygments_available = True
 try:
         if url_parsed[0] and not url_parsed[0].lower().startswith(u'http'):
             return ""
 
-        #Prepend http: if it is not present
-        if not url_parsed[0]:
-            self.url="http://"+self.url
-            url_parsed = urlparse(self.url)
+        if not settings.PYBB_ALLOW_RELATIVE_URLS:
+            #Prepend http: if it is not present
+            if not url_parsed[0]:
+                self.url="http://"+self.url
+                url_parsed = urlparse(self.url)
 
         #Get domain
         self.domain = url_parsed[1].lower()
 
         if not self.url:
             return u""
-
-        if self.domain:
+        
+        if self.domain or settings.PYBB_ALLOW_RELATIVE_URLS:
             return u'<a href="%s">'%self.url
         else:
             return u""
         if tag_data['link_nest_level'] > 0:
             return u''
 
-        if self.domain:
+        if self.domain or settings.PYBB_ALLOW_RELATIVE_URLS:
             return u'</a>'+self.annotate_link(self.domain)
         else:
             return u''

File pybb/settings.py

 
 PYBB_DEFAULT_USERS_GROUP = 'pybb-forum'
 PYBB_ANONYMOUS_GROUP = 'pybb-anonymous'
+
+# if yes relative urls can be used (/app/view/value/), not only http://....
+# this is requred if your app shuld make a posts related with some subject 
+# and put link to the subject in the post
+PYBB_ALLOW_RELATIVE_URLS = False