Changeset 3261089
- Timestamp:
- 03/24/2025 08:16:12 PM (12 months ago)
- Location:
- rps-include-content/tags/1.2.2
- Files:
-
- 2 edited
- 1 copied
-
. (copied) (copied from rps-include-content/tags/1.2.1)
-
readme.txt (modified) (2 diffs)
-
rps-include-content.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rps-include-content/tags/1.2.2/readme.txt
r3130091 r3261089 4 4 Tags: duplicate content, copy content, include, include content, includes, multisite, nested content, pull content, red pixel, red pixel studios, redpixelstudios, rps, same content 5 5 Requires at least: 5.0 6 Tested up to: 6. 6.17 Stable tag: 1.2. 16 Tested up to: 6.7.2 7 Stable tag: 1.2.2 8 8 License: GPL3 9 9 … … 154 154 == Upgrade Notice == 155 155 156 = 1.2.2 = 157 * Update sanitization handling of submitted shortcode attribute values. 158 * Sanitize output of more text to prevent potential code injection. 159 156 160 = 1.2.1 = 157 161 * Silenced a couple of notices related to variables being undefined. -
rps-include-content/tags/1.2.2/rps-include-content.php
r3130093 r3261089 4 4 Plugin URI: http://redpixel.com/ 5 5 Description: Adds the ability to include content on the current post or page from another. 6 Version: 1.2. 16 Version: 1.2.2 7 7 Author: Red Pixel Studios 8 8 Author URI: http://redpixel.com/ … … 32 32 * @package rps-include-content 33 33 * @author Red Pixel Studios 34 * @version 1.2. 134 * @version 1.2.2 35 35 */ 36 36 … … 45 45 * @since 1.0 46 46 */ 47 const PLUGIN_VERSION = '1.2. 1';47 const PLUGIN_VERSION = '1.2.2'; 48 48 49 49 /** … … 129 129 } 130 130 131 /** 132 * Helper to sanitize boolean shortcode values. 133 * 134 * @since 1.2.2 135 */ 136 private static function sanitize_bool_attr( $val, $default = false ) { 137 $bool = filter_var( $val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 138 return is_null( $bool ) ? $default : $bool; 139 } 140 141 /** 142 * Sanitize a value and fallback to a default if it's not in the allowed list. 143 * 144 * @since 1.2.2 145 * 146 * @param string $value The input value. 147 * @param callable $sanitize_cb A sanitization callback (e.g., 'sanitize_key', 'sanitize_html_class'). 148 * @param array $allowed Array of allowed values. 149 * @param mixed $default Fallback value if input is not allowed. 150 * @return mixed 151 */ 152 private static function sanitize_enum_attr( $value, $sanitize_cb, array $allowed, $default ) { 153 $sanitized = call_user_func( $sanitize_cb, $value ); 154 return in_array( $sanitized, $allowed, true ) ? $sanitized : $default; 155 } 156 131 157 public function cb_include_shortcode( $atts, $content = null ) { 132 158 global $shortcode_tags; 133 134 // specify allowed values for shortcode attributes 135 $allowed_titletag = array( 136 'h1', 137 'h2', 138 'h3', 139 'h4', 140 'h5', 141 'h6' 142 ); 143 144 $allowed_content = array( 145 'content', 146 'excerpt', 147 'lede', 148 'full', 149 'none' 150 ); 151 159 152 160 $current_blog_id = get_current_blog_id(); 153 161 … … 180 188 extract( shortcode_atts( $defaults, $atts ) ); 181 189 182 // convert string values to lowercase and trim 183 $title = trim( strtolower( $title ) ); 184 $titletag = trim( strtolower( $titletag ) ); 185 $content = trim( strtolower( $content ) ); 186 $allow_shortcodes = trim( strtolower( $allow_shortcodes ) ); 187 $allow_shortcodes_array = ( ! empty( $allow_shortcodes ) ) ? explode( ',', $allow_shortcodes ) : array(); 188 $allow_shortcodes_array = array_map( 'trim', $allow_shortcodes_array ); 189 190 // type cast strings as necessary 190 //sanitize shortcode atts 191 191 $blog = absint( $blog ); 192 192 $post = absint( $post ); 193 193 $page = absint( $page ); 194 $title = ( $title == 'true' ) ? true : false; 195 $titlelink = ( $titlelink == 'true' ) ? true : false; 196 $filter = ( $filter == 'true' ) ? true : false; 197 $embeds = ( $embeds == 'true' ) ? true : false; 198 $shortcodes = ( $shortcodes == 'true' ) ? true : false; 199 $length = ( $length == '0' || $length == '' ) ? 55 : absint( $length ); 200 $hover = ( $hover == 'true' ) ? true : false; 201 $private = ( $private == 'true' ) ? true : false; 202 $featured_image = ( $featured_image == 'true' ) ? true : false; 203 $featured_image_wrap = ( $featured_image_wrap == 'true' ) ? true : false; 204 194 $title = self::sanitize_bool_attr( $title ); 195 $titletag = self::sanitize_enum_attr( $titletag, 'sanitize_html_class', ['h1','h2','h3','h4','h5','h6'], $defaults['titletag'] ); 196 $titlelink = self::sanitize_bool_attr( $titlelink ); 197 $content = self::sanitize_enum_attr( $content, 'sanitize_key', ['content', 'excerpt', 'lede', 'full', 'none'], $defaults['content'] ); 198 $filter = self::sanitize_bool_attr( $filter ); 199 $shortcodes = self::sanitize_bool_attr( $shortcodes ); 200 $embeds = self::sanitize_bool_attr( $embeds ); 201 $more_text = sanitize_text_field( $more_text ); 202 $length = absint( $length ); 203 if ( $length <= 0 ) { 204 $length = $defaults['length']; 205 } 206 $allow_shortcodes_array = ! empty( $allow_shortcodes ) 207 ? array_map( 'trim', explode( ',', strtolower( sanitize_text_field( $allow_shortcodes ) ) ) ) 208 : array(); 209 $hover = self::sanitize_bool_attr( $hover ); 210 $private = self::sanitize_bool_attr( $private ); 211 $featured_image = self::sanitize_bool_attr( $featured_image ); 212 $featured_image_size = sanitize_key( $featured_image_size ); 213 $featured_image_wrap = self::sanitize_bool_attr( $featured_image_wrap ); 214 $featured_image_wrap_class = sanitize_html_class( $featured_image_wrap_class, '' ); 215 205 216 // handle if page attribute used instead of post 206 217 $post = ( $post === 0 && $page !== 0 ) ? $page : $post; 207 208 // test for allowed values and sanitize as necessary209 if ( !in_array( $titletag, $allowed_titletag ) ) $titletag = $defaults['titletag'];210 if ( !in_array( $content, $allowed_content ) ) $content = $defaults['content'];211 $featured_image_size = sanitize_text_field( $featured_image_size );212 $featured_image_wrap_class = sanitize_html_class( $featured_image_wrap_class, '' );213 214 218 if ( $post === 0 ) 215 219 return $this->error_msg( __( 'Post must be a non-zero integer.', 'rps-include-content' ), $hover ); … … 221 225 endif; 222 226 223 224 227 $the_post = ( is_multisite() ) ? get_blog_post( $blog, $post ) : get_post( $post ); 225 228 … … 299 302 endif; 300 303 301 $more_link = '<p class="more-link-container"><a href="'. $the_permalink .'#more-' . $the_post->ID . '" class="more-link">' . $more_text. '</a></p>';304 $more_link = '<p class="more-link-container"><a href="'. $the_permalink .'#more-' . $the_post->ID . '" class="more-link">' . esc_html( $more_text ) . '</a></p>'; 302 305 303 306 /**
Note: See TracChangeset
for help on using the changeset viewer.