Permalink
Browse files

MDL-19380 fix redirect when virus found in JS-less mode

  • Loading branch information...
1 parent 16dc846 commit 93e8c6c422d9cfc8171885bca214bcdbf6c342ac @skodak skodak committed with stronk7 Aug 18, 2011
Showing with 18 additions and 4 deletions.
  1. +18 −4 repository/filepicker.php
@@ -113,8 +113,15 @@
case 'upload':
// The uploaded file has been processed in plugin construct function
// redirect to default page
- $repo->upload('', $maxbytes);
- redirect($home_url, get_string('uploadsucc','repository'));
+ try {
+ $repo->upload('', $maxbytes);
+ redirect($home_url, get_string('uploadsucc','repository'));
+ } catch (moodle_exception $e) {
+ // inject target URL
+ $e->link = $PAGE->url->out();
+ echo $OUTPUT->header(); // hack: we need the embedded header here, standard error printing would not use it
+ throw $e;
+ }
break;
case 'search':
@@ -262,8 +269,15 @@
$record->license = '';
$record->author = '';
$record->source = $thefile['url'];
- $info = repository::move_to_filepool($thefile['path'], $record);
- redirect($home_url, get_string('downloadsucc', 'repository'));
+ try {
+ $info = repository::move_to_filepool($thefile['path'], $record);
+ redirect($home_url, get_string('downloadsucc', 'repository'));
+ } catch (moodle_exception $e) {
+ // inject target URL
+ $e->link = $PAGE->url->out();
+ echo $OUTPUT->header(); // hack: we need the embedded header here, standard error printing would not use it
+ throw $e;
+ }
} else {
print_error('cannotdownload', 'repository');
}

0 comments on commit 93e8c6c

Please sign in to comment.