Show More
@@ -3,6 +3,8 b' from datetime import time as dtime' | |||||
3 | import logging |
|
3 | import logging | |
4 | import re |
|
4 | import re | |
5 |
|
5 | |||
|
6 | from urllib.parse import unquote | |||
|
7 | ||||
6 | from adjacent import Client |
|
8 | from adjacent import Client | |
7 | from django.core.urlresolvers import reverse |
|
9 | from django.core.urlresolvers import reverse | |
8 | from django.db import models, transaction |
|
10 | from django.db import models, transaction | |
@@ -40,6 +42,7 b" NO_IP = '0.0.0.0'" | |||||
40 | UNKNOWN_UA = '' |
|
42 | UNKNOWN_UA = '' | |
41 |
|
43 | |||
42 | REGEX_REPLY = re.compile(r'\[post\](\d+)\[/post\]') |
|
44 | REGEX_REPLY = re.compile(r'\[post\](\d+)\[/post\]') | |
|
45 | REGEX_URL = re.compile(r'https?\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?') | |||
43 |
|
46 | |||
44 | PARAMETER_TRUNCATED = 'truncated' |
|
47 | PARAMETER_TRUNCATED = 'truncated' | |
45 | PARAMETER_TAG = 'tag' |
|
48 | PARAMETER_TAG = 'tag' | |
@@ -174,7 +177,7 b' class PostManager(models.Manager):' | |||||
174 |
|
177 | |||
175 | return ppd |
|
178 | return ppd | |
176 |
|
179 | |||
177 | def _preparse_text(self, text): |
|
180 | def _preparse_text(self, text: str) -> str: | |
178 | """ |
|
181 | """ | |
179 | Preparses text to change patterns like '>>' to a proper bbcode |
|
182 | Preparses text to change patterns like '>>' to a proper bbcode | |
180 | tags. |
|
183 | tags. | |
@@ -183,6 +186,9 b' class PostManager(models.Manager):' | |||||
183 | for key, value in PREPARSE_PATTERNS.items(): |
|
186 | for key, value in PREPARSE_PATTERNS.items(): | |
184 | text = re.sub(key, value, text, flags=re.MULTILINE) |
|
187 | text = re.sub(key, value, text, flags=re.MULTILINE) | |
185 |
|
188 | |||
|
189 | for link in REGEX_URL.findall(text): | |||
|
190 | text = text.replace(link, unquote(link)) | |||
|
191 | ||||
186 | return text |
|
192 | return text | |
187 |
|
193 | |||
188 |
|
194 |
General Comments 0
You need to be logged in to leave comments.
Login now