Skip to content

Commit

Permalink
fix(views): prevent direct calls to an ajax view
Browse files Browse the repository at this point in the history
fixes #4959
  • Loading branch information
jdalsem committed Apr 11, 2015
1 parent 251022f commit 3b5993b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions engine/lib/elgglib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,12 @@ function _elgg_js_page_handler($page) {
* @access private
*/
function _elgg_ajax_page_handler($page) {
// the ajax page handler should only be called from an xhr
if (!elgg_is_xhr()) {
register_error(_elgg_services()->translator->translate('ajax:not_is_xhr'));
forward(null, '400');
}

if (is_array($page) && sizeof($page)) {
// throw away 'view' and form the view name
unset($page[0]);
Expand Down
1 change: 1 addition & 0 deletions languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'actionunauthorized' => 'You are unauthorized to perform this action',

'ajax:error' => 'Unexpected error while performing an AJAX call. Maybe the connection to the server is lost.',
'ajax:not_is_xhr' => 'You cannot access AJAX views directly',

'PluginException:MisconfiguredPlugin' => "%s (guid: %s) is a misconfigured plugin. It has been disabled. Please search the Elgg wiki for possible causes (http://learn.elgg.org/).",
'PluginException:CannotStart' => '%s (guid: %s) cannot start and has been deactivated. Reason: %s',
Expand Down

0 comments on commit 3b5993b

Please sign in to comment.