Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize all shortcode atts #68

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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