Show More
@@ -15,9 +15,12 b' from boards.models import Tag, Post' | |||||
15 | from neboard import settings |
|
15 | from neboard import settings | |
16 | import boards.settings as board_settings |
|
16 | import boards.settings as board_settings | |
17 |
|
17 | |||
|
18 | HEADER_CONTENT_LENGTH = 'content-length' | |||
|
19 | HEADER_CONTENT_TYPE = 'content-type' | |||
18 |
|
20 | |||
19 | CONTENT_TYPE_IMAGE = ( |
|
21 | CONTENT_TYPE_IMAGE = ( | |
20 | 'image/jpeg', |
|
22 | 'image/jpeg', | |
|
23 | 'image/jpg', | |||
21 | 'image/png', |
|
24 | 'image/png', | |
22 | 'image/gif', |
|
25 | 'image/gif', | |
23 | 'image/bmp', |
|
26 | 'image/bmp', | |
@@ -298,9 +301,9 b' class PostForm(NeboardForm):' | |||||
298 | try: |
|
301 | try: | |
299 | # Verify content headers |
|
302 | # Verify content headers | |
300 | response_head = requests.head(url, verify=False) |
|
303 | response_head = requests.head(url, verify=False) | |
301 |
content_type = response_head.headers[ |
|
304 | content_type = response_head.headers[HEADER_CONTENT_TYPE].split(';')[0] | |
302 | if content_type in CONTENT_TYPE_IMAGE: |
|
305 | if content_type in CONTENT_TYPE_IMAGE: | |
303 |
length_header = response_head.headers.get( |
|
306 | length_header = response_head.headers.get(HEADER_CONTENT_LENGTH) | |
304 | if length_header: |
|
307 | if length_header: | |
305 | length = int(length_header) |
|
308 | length = int(length_header) | |
306 | self.validate_image_size(length) |
|
309 | self.validate_image_size(length) |
General Comments 0
You need to be logged in to leave comments.
Login now