Skip to content

Commit

Permalink
sanitize all short code attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
snrbrnjna committed Feb 25, 2023
1 parent aa79b1a commit ac4f291
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gigpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ function gigpress_prepare( $show, $scope = 'public' ) {
}


function gigpress_sanitize_sort($sort_value, $default = false, $safe_values = array('asc', 'desc')) {
if (!in_array($sort_value, $safe_values, true)) {
// DEBUG
debug_log('hui, seems, to have an SQL injection attempt here? "'. $sort_value . '"');
return $default;
}
return $sort_value;
}


function gigpress_related_link( $postid, $format) {

if ( $postid == 0 ) return;
Expand Down
2 changes: 2 additions & 0 deletions output/gigpress_related.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function gigpress_show_related($args = array(), $content = '') {
'sort' => 'asc'
), $args));

$sort = gigpress_sanitize_sort($sort, $default = 'asc');

// Date conditionals based on scope
switch($scope) {
case 'upcoming':
Expand Down
4 changes: 4 additions & 0 deletions output/gigpress_shows.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function gigpress_shows( $filter = null, $content = null ) {
), $filter )
);

$sort = gigpress_sanitize_sort($sort);

$total_artists = $wpdb->get_var( "SELECT count(*) from " . GIGPRESS_ARTISTS );

// Date conditionals and sorting based on scope
Expand Down Expand Up @@ -347,6 +349,8 @@ function gigpress_menu( $options = null ) {
'sort' => 'desc',
), $options ) );

$sort = gigpress_sanitize_sort($sort, $default='desc');

$base .= ( strpos( $base, '?' ) === false ) ? '?' : '&';

// Date conditionals based on scope
Expand Down

0 comments on commit ac4f291

Please sign in to comment.