Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/link-library/link-library.php
+++ b/link-library/link-library.php
@@ -3,7 +3,7 @@
Plugin Name: Link Library
Plugin URI: https://ylefebvre.github.io/wordpress-plugins/link-library/
Description: Display links on pages with a variety of options
-Version: 7.10.7
+Version: 7.10.8
Author: Yannick Lefebvre
Author URI: http://ylefebvre.github.io/
Text Domain: link-library
@@ -67,7 +67,7 @@
if ( $settings > $genoptions['numberstylesets'] ) {
$settings = 1;
}
-
+
return $settings;
}
@@ -315,7 +315,7 @@
add_filter( 'block_categories_all', array( $this, 'll_block_categories' ), 10, 2 );
add_action( 'rest_api_init', array( $this, 'll_rest_api_init' ) );
-
+
// Re-write rules filters to allow for custom permalinks
add_filter( 'rewrite_rules_array', array( $this, 'll_insertMyRewriteRules' ) );
@@ -391,7 +391,7 @@
function ll_rest_settings_list( WP_REST_Request $request ) {
$genoptions = get_option( 'LinkLibraryGeneral' );
$genoptions = wp_parse_args( $genoptions, ll_reset_gen_settings( 'return' ) );
-
+
if ( empty( $genoptions['numberstylesets'] ) ) {
$numberofsets = 1;
} else {
@@ -401,7 +401,7 @@
for ( $counter = 1; $counter <= $numberofsets; $counter ++ ) {
$tempoptionname = "LinkLibraryPP" . $counter;
$tempoptions = get_option( $tempoptionname );
-
+
if ( ! empty( $tempoptions ) && isset( $tempoptions['settingssetname'] ) ) {
$settings_array[$counter] = $tempoptions['settingssetname'];
}
@@ -444,7 +444,7 @@
} elseif ( isset( $qv['feed'] ) && isset( $qv['post_type'] ) ) {
$qv['post_type'][] = 'link_library_links';
}
-
+
return $qv;
}
@@ -529,7 +529,7 @@
$post_type_args['hierarchical'] = true;
$post_type_args['graphql_single_name'] = 'linklibrary';
$post_type_args['graphql_plural_name'] = 'linklibrary';
- }
+ }
if ( $genoptions['exclude_from_search'] && $genoptions['publicly_queryable'] ) {
unset( $post_type_args['exclude_from_search'] );
@@ -578,15 +578,15 @@
if ( function_exists( 'register_block_type' ) ) {
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php');
-
+
wp_register_script(
'link-library-block',
plugins_url( 'build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
-
- register_block_type( 'link-library/link-block', array(
+
+ register_block_type( 'link-library/link-block', array(
'editor_script' => 'link-library-block',
'render_callback' => array( $this, 'link_library_func' ),
'attributes' => array(
@@ -701,7 +701,7 @@
),
),
) );
-
+
register_block_type( 'link-library/addlink-block', array(
'editor_script' => 'link-library-block',
'render_callback' => array( $this, 'link_library_addlink_func' ),
@@ -734,7 +734,7 @@
),
),
) );
- }
+ }
}
function link_library_block_callback( $attributes ) {
@@ -744,23 +744,23 @@
$settings = $attributes['settingsid'];
$settings = link_library_validate_settings_number( $settings );
}
-
+
$genoptions = get_option( 'LinkLibraryGeneral' );
$genoptions = wp_parse_args( $genoptions, ll_reset_gen_settings( 'return' ) );
$linkcount = 1;
-
+
$settingsname = 'LinkLibraryPP' . $settings;
$options = get_option( $settingsname );
$options = wp_parse_args( $options, ll_reset_options( 1, 'list', 'return' ) );
if ( isset( $attributes['categoryOverrideArray'] ) && !empty( $attributes['categoryOverrideArray'] ) ) {
$options['categorylist_cpt'] = implode( ',', $attributes['categoryOverrideArray'] );
- }
+ }
require_once plugin_dir_path( __FILE__ ) . 'render-link-library-sc.php';
-
- return RenderLinkLibrary( $linkcount, $this, $genoptions, $options, $settings, false, 0, 0, true, false );
+
+ return RenderLinkLibrary( $linkcount, $this, $genoptions, $options, $settings, false, 0, 0, true, false );
}
function link_library_cats_block_callback( $attributes ) {
@@ -770,24 +770,24 @@
$settings = $attributes['settingsid'];
$settings = link_library_validate_settings_number( $settings );
}
-
+
$genoptions = get_option( 'LinkLibraryGeneral' );
$genoptions = wp_parse_args( $genoptions, ll_reset_gen_settings( 'return' ) );
$linkcount = 1;
-
+
$settingsname = 'LinkLibraryPP' . $settings;
$options = get_option( $settingsname );
$options = wp_parse_args( $options, ll_reset_options( 1, 'list', 'return' ) );
if ( isset( $attributes['categoryOverrideArray'] ) && !empty( $attributes['categoryOverrideArray'] ) ) {
$options['categorylist_cpt'] = implode( ',', $attributes['categoryOverrideArray'] );
- }
+ }
$targetlibrary = $settings;
require_once plugin_dir_path( __FILE__ ) . 'render-link-library-cats-sc.php';
-
- return RenderLinkLibraryCategories( $this, $genoptions, $options, $settings, $targetlibrary );
+
+ return RenderLinkLibraryCategories( $this, $genoptions, $options, $settings, $targetlibrary );
}
function ll_update_60() {
@@ -831,7 +831,7 @@
if ( !current_user_can( 'manage_options' ) ) {
return;
}
-
+
require plugin_dir_path( __FILE__ ) . 'link-library-update-60.php';
link_library_60_update( $this );
}
@@ -1080,7 +1080,7 @@
echo esc_html( stripslashes( sanitize_text_field( $options['stylesheet'] ) ) ) . "n";
echo "</style>n";
}
- }
+ }
}
}
}
@@ -1128,11 +1128,11 @@
if ( !empty( $link_url ) ) {
return $link_url;
- }
+ }
}
}
- return $url;
+ return $url;
}
function ll_get_title( $title, $id = null ) {
@@ -1143,7 +1143,7 @@
$post = get_post( $id );
if ( $post instanceof WP_Post && !empty( $genoptions['globalsearchresultstitleprefix'] ) ) {
return $genoptions['globalsearchresultstitleprefix'] . $title;
- }
+ }
}
return $title;
@@ -1249,7 +1249,7 @@
if ( $original_host_segments[ sizeof( $original_host_segments ) - 1 ] == $actual_host_segments[ sizeof( $actual_host_segments ) - 1] && $original_host_segments[ sizeof( $original_host_segments ) - 2 ] == $actual_host_segments[ sizeof( $actual_host_segments ) - 2] ) {
return 'exists_subdomain_redirect';
}
- }
+ }
}
if ( ( 'broken' == $request_type || 'rss' == $request_type || 'secondary' == $request_type || 'image' == $request_type ) && $parse_original_url['host'] == $parse_actual_url['host'] && $link_url_without_protocol != $response_url_without_protocol ) {
@@ -1258,9 +1258,9 @@
return 'exists_redirected_fileurl';
} else {
return 'exists_redirected_subfolder';
- }
+ }
}
-
+
if ( ( 'broken' == $request_type || 'rss' == $request_type || 'secondary' == $request_type || 'image' == $request_type ) && $link_url_without_protocol != $response_url_without_protocol ) {
return 'exists_redirected';
} elseif ( ( 'broken' == $request_type || 'rss' == $request_type || 'secondary' == $request_type || 'image' == $request_type ) && !empty( $original_protocol ) && !empty( $actual_protocol ) && $original_protocol != $actual_protocol ) {
@@ -1269,8 +1269,8 @@
return 'exists_notfound';
} else {
return 'exists_found';
- }
-
+ }
+
if ( 'reciprocal' == $request_type && strpos( $response['body'], $RecipCheckAddress ) === false ) {
return 'exists_notfound';
} elseif ( 'reciprocal' == $request_type && strpos( $response['body'], $RecipCheckAddress ) !== false ) {
@@ -1555,7 +1555,7 @@
} elseif ( 'popup' == $options['addlinkformdisplaymode'] ) {
return RenderLinkLibraryAddLinkButton( $this, $genoptions, $options, intval( $settings ), $code );
}
-
+
}
/********************************************** Function to Process [link-library-count] shortcode ***************************************/
@@ -1725,10 +1725,10 @@
if ( isset( $atts['taglistoverride'] ) && !empty( $atts['taglistoverride'] ) && is_array( $atts['taglistoverride'] ) ) {
$atts['taglistoverride'] = implode( ',', $atts['taglistoverride'] );
}
-
+
if ( isset( $atts['taglistoverrideCSV'] ) && !empty( $atts['taglistoverrideCSV'] ) ) {
$atts['taglistoverride'] = $atts['taglistoverrideCSV'];
- }
+ }
extract( shortcode_atts( array(
'categorylistoverride' => '',
@@ -1992,10 +1992,10 @@
if ( isset( $atts['taglistoverride'] ) && !empty( $atts['taglistoverride'] ) && is_array( $atts['taglistoverride'] ) ) {
$atts['taglistoverride'] = implode( ',', $atts['taglistoverride'] );
}
-
+
if ( isset( $atts['taglistoverrideCSV'] ) && !empty( $atts['taglistoverrideCSV'] ) ) {
$atts['taglistoverride'] = $atts['taglistoverrideCSV'];
- }
+ }
extract( shortcode_atts( array(
'settings' => '',
@@ -2131,12 +2131,12 @@
$timeoutput = "n<!-- [link-library] shortcode execution time: " . ( microtime( true ) - $mainoutputstarttime ) . "-->n";
}
return $linklibraryoutput . ( true == $genoptions['debugmode'] ? $timeoutput : '' );
- }
+ }
function link_library_tagcloud( $atts = '' ) {
$genoptions = get_option( 'LinkLibraryGeneral' );
$genoptions = wp_parse_args( $genoptions, ll_reset_gen_settings( 'return' ) );
-
+
$link_library_terms = get_terms( array( 'taxonomy' => $genoptions['cattaxonomy'] ) );
$output = wp_generate_tag_cloud( $link_library_terms );
return $output;
@@ -2190,30 +2190,30 @@
foreach ( $atts_list as $key => $value ) {
if ( $key = 'settings' && ( empty( $settingssetsids ) || false === array_search( $value, $settingssetsids ) ) ) {
$settingssetsids[] = intval( $value );
- }
- }
+ }
+ }
} else {
$settingssetsids[] = 1;
}
-
- }
- }
+
+ }
+ }
}
}
if ( function_exists( 'has_blocks' ) && function_exists( 'parse_blocks' ) ) {
if ( has_blocks( $post->ID ) ) {
$blocks = parse_blocks( $post->post_content );
-
+
foreach ( $blocks as $block ) {
if ( in_array( $block['blockName'], array( 'link-library/link-block', 'link-library/cat-block', 'link-library/search-block', 'link-library/addlink-block', 'link-library/count-block' ) ) ) {
$load_style = true;
}
-
+
if ( in_array( $block['blockName'], array( 'link-library/addlink-block' ) ) ) {
$load_recaptcha = true;
}
-
+
if ( isset( $block['attr']['settings'] ) && false === array_search( $block['attr']['settings'], $settingssetsids ) ) {
$settingssetsids[] = $block['attr']['settings'];
} elseif ( !isset( $block['attr']['settings'] ) ) {
@@ -2221,7 +2221,7 @@
}
}
}
- }
+ }
}
}
@@ -2301,7 +2301,7 @@
if ( $load_masonry ) {
wp_enqueue_script( 'jquery-masonry' );
- }
+ }
return $posts;
}
@@ -2373,12 +2373,12 @@
$genoptions = wp_parse_args( $genoptions, ll_reset_gen_settings( 'return' ) );
if ( ( is_search() || is_feed() ) && 'link_library_links' == get_post_type() ) {
- $content = htmlspecialchars_decode( stripslashes( $genoptions['global_search_results_layout'] ) );
+ $content = htmlspecialchars_decode( stripslashes( $genoptions['global_search_results_layout'] ) );
} elseif ( is_single() && 'link_library_links' == get_post_type() ) {
$content = htmlspecialchars_decode( stripslashes( $genoptions['single_link_layout'] ) );
} else {
return $content;
- }
+ }
$item_id = get_the_ID();
if ( !empty( $item_id ) ) {
@@ -2589,7 +2589,7 @@
if ( !empty( $category_list_override ) ) {
$shortcode_string .= ' categorylistoverride="' . $category_list_override . '"';
}
-
+
$shortcode_string .= ']';
echo do_shortcode( $shortcode_string );
@@ -2614,7 +2614,7 @@
if ( !$terms && basename( $_SERVER['PHP_SELF'] ) == 'post-new.php' ) {
// Category - note: only 1 category is supported currently
- if ( $taxonomies == "'link_library_category'" && isset( $_REQUEST['link_library_cat'] ) ) {
+ if ( $taxonomies == "'link_library_category'" && isset( $_REQUEST['link_library_cat'] ) ) {
$id = intval( $_REQUEST['link_library_cat'] );
if ( $id ) {
--- a/link-library/render-link-library-sc.php
+++ b/link-library/render-link-library-sc.php
@@ -33,26 +33,26 @@
$genoptions = wp_parse_args( $genoptions, ll_reset_gen_settings( 'return' ) );
$matches = $genoptions['ignoresortarticles'];;
- $has_the = " CASE
+ $has_the = " CASE
WHEN $wpdb->posts.post_title regexp( '^($matches)[[:space:]]' )
- THEN trim(substr($wpdb->posts.post_title from 4))
- ELSE $wpdb->posts.post_title
+ THEN trim(substr($wpdb->posts.post_title from 4))
+ ELSE $wpdb->posts.post_title
END AS title2";
if ( $has_the ) {
$fields .= ( preg_match( '/^(s+)?,/', $has_the ) ) ? $has_the : ", $has_the";
}
return $fields;
}
-
+
function ll_sort_by_temp_column ( $orderby ) {
$custom_orderby = '';
-
+
global $globallibraryoptions;
-
+
if ( $globallibraryoptions['featuredfirst'] && 'random' != $globallibraryoptions['linkorder'] ) {
$custom_orderby = 'wp_postmeta.meta_value+0 DESC, ';
}
-
+
$custom_orderby .= " UPPER(title2) ASC";
if ( $custom_orderby ) {
$orderby = $custom_orderby;
@@ -85,7 +85,7 @@
}
if ( $level != 0 ) {
- $cat_path .= '<a href="' . esc_url( $new_link ) . '">' . $term->name . '</a>';
+ $cat_path .= '<a href="' . esc_url( $new_link ) . '">' . $term->name . '</a>';
} elseif ( $level == 0 ) {
$cat_path .= $term->name;
$new_top_link = home_url() . '/' . $rewritecategoriespage . '/';
@@ -250,7 +250,7 @@
} else {
$argumentarray = array ( 'linkresultpage' => $nextpagenumber, 'cat' => $AJAXcatid );
}
-
+
$argumentarray = array_merge( $argumentarray, $incomingget );
$targetaddress = esc_url( add_query_arg( $argumentarray ) );
@@ -711,7 +711,7 @@
$args = array(
'post_type' => 'link_library_links',
- 'tax_query' => array(
+ 'tax_query' => array(
array(
'taxonomy' => $generaloptions['cattaxonomy'],
'field' => 'term_id',
@@ -722,7 +722,7 @@
);
if ( !empty( $tag_array ) ) {
- $args['tax_query'][] = array(
+ $args['tax_query'][] = array(
array(
'taxonomy' => $generaloptions['tagtaxonomy'],
'field' => $tag_type,
@@ -735,7 +735,7 @@
$args['tax_query']['relation'] = 'AND';
}
- $posts_array = get_posts( $args );
+ $posts_array = get_posts( $args );
$number_of_links += sizeof( $posts_array );
$link_categories[$cat_array_index]->count = sizeof( $posts_array );
@@ -772,7 +772,7 @@
if ( 'categorymasonrygrid' == $displayastable ) {
$output .= ' grid';
}
-
+
$output .= "'><!-- Div Linklist -->n";
}
@@ -844,8 +844,8 @@
'terms' => explode( ',', $categorylist_cpt ),
'include_children' => false
);
- }
-
+ }
+
if ( !empty( $excludecategorylist_cpt ) ) {
$link_query_args['tax_query'][] =
array(
@@ -885,7 +885,7 @@
'field' => 'id',
'terms' => $tag_array,
);
- }
+ }
}
if ( !empty( $excludetaglist_cpt ) ) {
@@ -936,7 +936,7 @@
if ( !empty( $customqueryarg ) && !empty( $customqueryargvalue ) ) {
$link_query_args[$customqueryarg] = $customqueryargvalue;
- }
+ }
if ( isset( $_GET['linkname'] ) && in_array( $_GET['linkname'], array( 'ASC', 'DESC' ) ) ) {
$linkorder = 'name';
@@ -1064,7 +1064,7 @@
if ( $debugmode ) {
foreach ( $link_query_args as $key => $value ) {
-
+
if ( is_array( $link_query_args[$key] ) ) {
foreach ( $link_query_args[$key] as $lower_key => $lower_value ) {
if ( is_array( $link_query_args[$key][$lower_key] ) ) {
@@ -1073,7 +1073,7 @@
}
} else {
$link_query_args[$key][$lower_key] = esc_html( $lower_value );
- }
+ }
}
} else {
$link_query_args[$key] = esc_html( $value );
@@ -1119,11 +1119,11 @@
if ( ! $combineresults ) {
$currentcategoryid = $link_category->term_id;
$current_cat_output .= '<div class="LinkLibraryCat LinkLibraryCat' . $currentcategoryid;
-
+
if ( 'categorymasonrygrid' == $displayastable ) {
$current_cat_output .= ' ll-grid-item ';
}
-
+
$current_cat_output .= ( $level == 0 ? '' : ' childlevel'). ' level' . $level .'"><!-- Div Category -->';
$catlink = '';
@@ -1732,7 +1732,7 @@
$new_rss_item['title'] = $item->get_title();
$new_rss_item['description'] = $item->get_description();
- $rss_array_items[] = $new_rss_item;
+ $rss_array_items[] = $new_rss_item;
}
}
@@ -1745,7 +1745,7 @@
}
set_transient( 'Link' . get_the_ID() . 'RSSItems', $rss_array_items, $rsscachedelay );
- }
+ }
if ( true == $debugmode ) {
$current_cat_output .= "n<!-- Time to render RSS Feed section of link id " . $linkitem['proper_link_id'] . ': ' . ( microtime( true ) - $starttimerssfeed ) . " --> n";
@@ -1852,11 +1852,11 @@
$target = $linkitem['link_target'];
if ( !empty( $target ) ) {
- $target = ' target="' . $target . '"';
+ $target = ' target="' . esc_attr( $target ) . '"';
} else {
$target = $linktarget;
if ( !empty( $target ) ) {
- $target = ' target="' . $target . '"';
+ $target = ' target="' . esc_attr( $target ) . '"';
}
}
@@ -1905,7 +1905,7 @@
$imageoutput .= admin_url( 'admin-ajax.php' . '?action=link_library_popup_content&linkid=' . $linkitem['proper_link_id'] . '&settings=' . $settings . '&height=' . ( empty( $popup_height ) ? 300 : $popup_height ) . '&width=' . ( empty( $popup_width ) ? 400 : $popup_width ) . '&xpath=' . $xpath . '&settingsnonce=' . wp_create_nonce( 'll_popup_setting_' . $settings . '_linkid_' . $linkitem['proper_link_id'] ) );
}
- $imageoutput .= '" id="link-' . $linkitem['proper_link_id'] . '" class="' . ( $enable_link_popup ? 'thickbox' : 'track_this_link' ) . ' ' . ( $linkitem['link_featured'] ? 'featured' : '' ). '" ' . $linkitem['link_rel'] . esc_html( $title ) . esc_html( $target ) . '>';
+ $imageoutput .= '" id="link-' . $linkitem['proper_link_id'] . '" class="' . ( $enable_link_popup ? 'thickbox' : 'track_this_link' ) . ' ' . ( $linkitem['link_featured'] ? 'featured' : '' ). '" ' . $linkitem['link_rel'] . $title . $target . '>';
}
if ( $usethumbshotsforimages && ( !$uselocalimagesoverthumbshots || empty( $uselocalimagesoverthumbshots ) || ( $uselocalimagesoverthumbshots && empty( $linkitem['link_image'] ) ) ) ) {
@@ -2001,12 +2001,12 @@
}
if ( 'description' == $tooltipname && !empty( $desc ) ) {
- $title = ' title="' . $cleandesc . '"';
+ $title = ' title="' . esc_attr( $cleandesc ) . '"';
} else {
$title = '';
}
- $current_cat_output .= '" id="link-' . $linkitem['proper_link_id'] . '" class="' . ( $enable_link_popup ? 'thickbox' : 'track_this_link' ) . ' ' . ( $linkitem['link_featured'] ? ' featured' : '' ). '" ' . $linkitem['link_rel'] . esc_html( $title ) . esc_html( $target ) . '>';
+ $current_cat_output .= '" id="link-' . $linkitem['proper_link_id'] . '" class="' . ( $enable_link_popup ? 'thickbox' : 'track_this_link' ) . ' ' . ( $linkitem['link_featured'] ? ' featured' : '' ). '" ' . $linkitem['link_rel'] . $title . $target . '>';
}
$current_cat_output .= $name;
@@ -2587,12 +2587,12 @@
$cat_url = esc_url( site_url() . '/' . $rewritepage . '/' . $link_term->slug );
} else {
$cat_url = get_term_meta( $link_term->term_id, 'linkcaturl', true );
- }
-
+ }
+
if ( !empty( $cat_url ) ) {
$link_cat_string .= '<a href="' . $cat_url . '">';
}
-
+
$link_cat_string .= $link_term->name;
if ( !empty( $cat_url ) ) {
@@ -2605,7 +2605,7 @@
if ( !empty( $link_terms_array ) ) {
$current_cat_output .= implode( $categoryseparator, $link_terms_array );
}
- }
+ }
if ( true == $debugmode ) {
$current_cat_output .= "n<!-- Time to render category name section of link id " . $linkitem['proper_link_id'] . ': ' . ( microtime( true ) - $starttimedesc ) . " --> n";
@@ -2926,14 +2926,14 @@
$output .= "jQuery(document).ready(function()n";
$output .= "{n";
-
+
if ( 'linkmasonrygrid' == $displayastable || 'categorymasonrygrid' == $displayastable ) {
$output .= "jQuery( '.grid' ).masonry({n";
$output .= "titemSelector: '.ll-grid-item',n";
$output .= "tcolumnWidth: 1n";
$output .= "});n";
}
-
+
$output .= "jQuery('.arrow-up').hide();n";
$output .= "jQuery('#linklist" . $settings . " a.track_this_link').click(function() {n";
$output .= "linkid = this.id;n";
@@ -3004,7 +3004,7 @@
if ( $level == 0 ) {
if ( !$suppresslinksdiv ) {
$output .= '</div><!-- Div Linklist -->';
- }
+ }
$output .= "n<!-- End of Link Library Output -->nn";
}