Skip to content

Commit

Permalink
Merge pull request #68 from snrbrnjna/sanitize-all-shortcode-atts
Browse files Browse the repository at this point in the history
Sanitize all shortcode atts
  • Loading branch information
bordoni authored Apr 27, 2023
2 parents 70a944b + 740f669 commit d1099bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions gigpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ 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)) {
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 @@ -23,6 +23,8 @@ function gigpress_show_related( $args = [], $content = '' ) {
$sort = 'asc';
}

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

// Date conditionals based on scope
switch ( $arguments['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
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If you want to go beyond GigPress, we also have other plugins that could work gr

= 2.3.29 [2023-04-27] =

* Tweak - Resolve a problematic usage of the shortcode `[gigpress_related]` improving the safety of the plugin.
* Tweak - Resolve a problematic usage of the shortcodes params improving the safety of the plugin.

= 2.3.28 [2022-12-27] =

Expand Down

0 comments on commit d1099bd

Please sign in to comment.