PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 All 503 releases
← All changes | modules/shortcodes/flickr.php +22 -14 12.9.516.2 View file →
@@ -14,8 +14,12 @@
14 14 *
15 15 * @package automattic/jetpack
16 16 */
17 17
18 +if ( ! defined( 'ABSPATH' ) ) {
19 + exit( 0 );
20 +}
21 +
18 22 /**
19 23 * Transform embed to shortcode on save.
20 24 *
21 25 * @param string $content Post content.
@@ -37,9 +41,9 @@
37 41 }
38 42
39 43 /**
40 44 * Transforms embed to shortcode on save when the photo param is used.
41 - * If embed content can not be transformed to a valid shortcode,
45 + * If embed content cannot be transformed to a valid shortcode,
42 46 * the embed content itself is returned.
43 47 *
44 48 * @param string $content Embed output.
45 49 *
@@ -63,9 +67,9 @@
63 67 }
64 68
65 69 /**
66 70 * Transforms embed to shortcode on save when the video param is used.
67 - * If embed content can not be transformed to a valid shortcode,
71 + * If embed content cannot be transformed to a valid shortcode,
68 72 * the embed content itself is returned.
69 73 *
70 74 * @param string $content Embed output.
71 75 *
@@ -100,9 +104,11 @@
100 104
101 105 return '[flickr video="' . $video_src . '" ' . $width . ' ' . $height . ' controls="' . $controls . '" autoplay="' . $autoplay . '"]';
102 106 }
103 107
104 -add_filter( 'pre_kses', 'flickr_embed_to_shortcode' );
108 +if ( jetpack_shortcodes_should_hook_pre_kses() ) {
109 + add_filter( 'pre_kses', 'flickr_embed_to_shortcode' );
110 +}
105 111
106 112 /**
107 113 * Flickr Shortcode handler.
108 114 *
@@ -187,10 +193,9 @@
187 193 if ( ! is_numeric( $video_param ) ) {
188 194 $video_url = $video_param;
189 195 } else {
190 196 // Get the URL of the video from the page of the video.
191 - $video_page_content = wp_remote_get( "http://flickr.com/photo.gne?id=$video_param" );
192 -
197 + $video_page_content = wp_remote_get( "https://flickr.com/photo.gne?id=$video_param" );
193 198 // Bail if we do not get any info from Flickr.
194 199 if ( is_wp_error( $video_page_content ) ) {
195 200 return '';
196 201 }
@@ -212,8 +217,11 @@
212 217
213 218 // Get the embed url.
214 219 preg_match( '/src=\"([^\"]+)\"/', $data['html'], $matches );
215 220
221 + if ( empty( $matches[1] ) ) {
222 + return '';
223 + }
216 224 $embed_url = $matches[1];
217 225
218 226 $embed_page = wp_remote_get( $embed_url );
219 227
@@ -224,12 +232,12 @@
224 232
225 233 // Get the video url from embed html markup.
226 234
227 235 preg_match( '/video.+src=\"([^\"]+)\"/', $embed_page['body'], $matches );
228 -
229 - $video_src = $matches[1];
230 -
231 - set_transient( $transient_name, $video_src, 2592000 ); // 30 days transient.
236 + if ( ! empty( $matches[1] ) ) {
237 + $video_src = $matches[1];
238 + set_transient( $transient_name, $video_src, 2592000 ); // 30 days transient.
239 + }
232 240 }
233 241
234 242 $style = 'max-width: 100%;';
235 243
@@ -288,11 +296,11 @@
288 296 * Callback to modify output of embedded Vimeo video using Jetpack's shortcode.
289 297 *
290 298 * @since 3.9
291 299 *
292 - * @param array $matches Regex partial matches against the URL passed.
293 - * @param array $attr Attributes received in embed response.
294 - * @param array $url Requested URL to be embedded.
300 + * @param array $matches Regex partial matches against the URL passed.
301 + * @param array $attr Attributes received in embed response.
302 + * @param string $url Requested URL to be embedded.
295 303 *
296 304 * @return string Return output of Vimeo shortcode with the proper markup.
297 305 */
298 306 function jetpack_flickr_oembed_handler( $matches, $attr, $url ) {
@@ -297,13 +305,13 @@
297 305 */
298 306 function jetpack_flickr_oembed_handler( $matches, $attr, $url ) {
299 307 /*
300 308 * Legacy slideshow embeds end with /show/
301 - * e.g. http://www.flickr.com/photos/yarnaholic/sets/72157615194738969/show/
309 + * e.g. https://www.flickr.com/photos/yarnaholic/sets/72157615194738969/show/
302 310 */
303 311 if ( '/show/' !== substr( $url, -strlen( '/show/' ) ) ) {
304 312 // These lookups need cached, as they don't use WP_Embed (which caches).
305 - $cache_key = md5( $url . wp_json_encode( $attr ) );
313 + $cache_key = md5( $url . wp_json_encode( $attr, JSON_UNESCAPED_SLASHES ) );
306 314 $cache_group = 'oembed_flickr';
307 315
308 316 $html = wp_cache_get( $cache_key, $cache_group );
309 317