diff options
Diffstat (limited to 'mediagoblin/submit')
-rw-r--r-- | mediagoblin/submit/security.py | 26 | ||||
-rw-r--r-- | mediagoblin/submit/views.py | 24 |
2 files changed, 15 insertions, 35 deletions
diff --git a/mediagoblin/submit/security.py b/mediagoblin/submit/security.py deleted file mode 100644 index 5dbc0db4..00000000 --- a/mediagoblin/submit/security.py +++ /dev/null @@ -1,26 +0,0 @@ -# GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -from mimetypes import guess_type - -ALLOWED = ['image/jpeg', 'image/png', 'image/tiff', 'image/gif'] - - -def check_filetype(posted_file): - if not guess_type(posted_file.filename)[0] in ALLOWED: - return False - - return True diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index 1e145e9d..517fb646 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -20,7 +20,8 @@ from os.path import splitext from cgi import FieldStorage from celery import registry -import urllib,urllib2 +import urllib +import urllib2 import logging _log = logging.getLogger(__name__) @@ -32,10 +33,11 @@ from mediagoblin.tools.text import convert_to_tag_list_of_dicts from mediagoblin.tools.translate import pass_to_ugettext as _ from mediagoblin.tools.response import render_to_response, redirect from mediagoblin.decorators import require_active_login -from mediagoblin.submit import forms as submit_forms, security -from mediagoblin.processing import mark_entry_failed, ProcessMedia +from mediagoblin.submit import forms as submit_forms +from mediagoblin.processing import mark_entry_failed +from mediagoblin.processing.task import ProcessMedia from mediagoblin.messages import add_message, SUCCESS -from mediagoblin.media_types import get_media_type_and_manager, \ +from mediagoblin.media_types import sniff_media, \ InvalidFileType, FileTypeNotSupported @@ -55,7 +57,11 @@ def submit_start(request): else: try: filename = request.POST['file'].filename - media_type, media_manager = get_media_type_and_manager(filename) + + # Sniff the submitted media to determine which + # media plugin should handle processing + media_type, media_manager = sniff_media( + request.POST['file']) # create entry and save in database entry = request.db.MediaEntry() @@ -130,9 +136,10 @@ def submit_start(request): raise if mg_globals.app_config["push_urls"]: - feed_url=request.urlgen( + feed_url = request.urlgen( 'mediagoblin.user_pages.atom_feed', - qualified=True,user=request.user.username) + qualified=True, + user=request.user.username) hubparameters = { 'hub.mode': 'publish', 'hub.url': feed_url} @@ -159,10 +166,9 @@ def submit_start(request): user=request.user.username) except Exception as e: ''' - This section is intended to catch exceptions raised in + This section is intended to catch exceptions raised in mediagobling.media_types ''' - if isinstance(e, InvalidFileType) or \ isinstance(e, FileTypeNotSupported): submit_form.file.errors.append( |