WP YouTube Lyte - Version 1.7.21

Version Description

  • bugfix for regression in parsing improvements which in some cases saw links to youtube being shown as LYTE as well.
  • improvement to lyteCache request sanitation (hat tip to Siina Chavoshlu for reporting & testing the fix)
  • other minor changes, see GitHub commits
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 1.7.21
Comparing to
See all releases

Code changes from version 1.7.20 to 1.7.21

Files changed (3) hide show
  1. lyteCache.php +16 -2
  2. readme.txt +7 -2
  3. wp-youtube-lyte.php +5 -4
lyteCache.php CHANGED
@@ -221,8 +221,17 @@ function get_origThumbURL() {
221
 
222
  // make sure the thumbnail-domain is for youtube.
223
  $origThumbDomain = $origThumbURL_parts['host'];
224
- if ( ! $invalid && str_replace( array( 'ytimg.com','youtube.com','youtu.be' ), '', $origThumbDomain ) === $origThumbDomain ) {
225
- $invalid = true;
 
 
 
 
 
 
 
 
 
226
  }
227
 
228
  // and make sure the thumbnail-url is for an image (.jpg)
@@ -261,3 +270,8 @@ function lyte_thumb_fallback() {
261
  header('Location: '. $origThumbURL );
262
  exit;
263
  }
 
 
 
 
 
221
 
222
  // make sure the thumbnail-domain is for youtube.
223
  $origThumbDomain = $origThumbURL_parts['host'];
224
+ if ( ! $invalid ) {
225
+ $_needle_ok = false;
226
+ foreach( array( 'ytimg.com','youtube.com','youtu.be' ) as $_needle ) {
227
+ if ( str_ends_in( $origThumbDomain, $_needle ) ) {
228
+ $_needle_ok = true;
229
+ break;
230
+ }
231
+ }
232
+ if ( ! $_needle_ok ) {
233
+ $invalid = true;
234
+ }
235
  }
236
 
237
  // and make sure the thumbnail-url is for an image (.jpg)
270
  header('Location: '. $origThumbURL );
271
  exit;
272
  }
273
+
274
+ function str_ends_in( $haystack, $needle ) {
275
+ $length = strlen( $needle );
276
+ return ( substr( $haystack, -$length, $length ) === $needle );
277
+ }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: futtta, optimizingmatters
3
  Tags: youtube, video, performance, gdpr, lazy load
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 4.0
6
- Tested up to: 6.0
7
- Stable tag: 1.7.20
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
@@ -143,6 +143,11 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
143
 
144
  == Changelog ==
145
 
 
 
 
 
 
146
  = 1.7.20 =
147
  * misc. parsing improvements, resulting in YT shorts working as well.
148
 
3
  Tags: youtube, video, performance, gdpr, lazy load
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 4.0
6
+ Tested up to: 6.1
7
+ Stable tag: 1.7.21
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
143
 
144
  == Changelog ==
145
 
146
+ = 1.7.21 =
147
+ * bugfix for regression in parsing improvements which in some cases saw links to youtube being shown as LYTE as well.
148
+ * improvement to lyteCache request sanitation (hat tip to Siina Chavoshlu for reporting & testing the fix)
149
+ * other minor changes, see [GitHub commits](https://github.com/futtta/wp-youtube-lyte/commits/main)
150
+
151
  = 1.7.20 =
152
  * misc. parsing improvements, resulting in YT shorts working as well.
153
 
wp-youtube-lyte.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP YouTube Lyte
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 1.7.20
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  */
@@ -14,7 +14,7 @@ Text Domain: wp-youtube-lyte
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
  $debug = false;
17
- $lyte_version = '1.7.20';
18
  $lyte_db_version = get_option( 'lyte_version', 'none' );
19
 
20
  /** have we updated? */
@@ -251,7 +251,7 @@ function lyte_parse( $the_content, $doExcerpt = false ) {
251
  break;
252
  default:
253
  $noscript_post = '';
254
- $lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] . '">' . __( 'Watch this video', 'wp-youtube-lyte' ) . ' <a href="' . $lyteSettings['scheme'] . '://youtu.be/' . $vid . '">' . __( 'on YouTube', 'wp-youtube-lyte' ) . '</a>.</div>';
255
  }
256
  $thumbUrl = $lyteSettings['scheme'] . '://i.ytimg.com/vi/' . $vid . '/0.jpg';
257
  if ( get_option( 'lyte_local_thumb', '0' ) === '1' ) {
@@ -794,7 +794,8 @@ function lyte_prepare( $the_content ) {
794
  if ( false !== strpos( $the_content, $prep_repla['tell'] ) && preg_match_all( $prep_repla['regex'], $the_content, $vids, PREG_SET_ORDER ) ) {
795
  foreach ( $vids as $vid ) {
796
  if ( is_array( $vid ) && array_key_exists( 1, $vid ) && false === strpos( trim( $vid[0] ), ' ' ) ) {
797
- $the_content = str_replace( $vid[1], $prep_repla['replace'], $the_content );
 
798
  }
799
  }
800
  }
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 1.7.21
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  */
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
  $debug = false;
17
+ $lyte_version = '1.7.21';
18
  $lyte_db_version = get_option( 'lyte_version', 'none' );
19
 
20
  /** have we updated? */
251
  break;
252
  default:
253
  $noscript_post = '';
254
+ $lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] . '">' . ' <a href="' . $lyteSettings['scheme'] . '://youtu.be/' . $vid . '" target="_blank">' . __( 'Watch this video on YouTube', 'wp-youtube-lyte' ) . '</a>.</div>';
255
  }
256
  $thumbUrl = $lyteSettings['scheme'] . '://i.ytimg.com/vi/' . $vid . '/0.jpg';
257
  if ( get_option( 'lyte_local_thumb', '0' ) === '1' ) {
794
  if ( false !== strpos( $the_content, $prep_repla['tell'] ) && preg_match_all( $prep_repla['regex'], $the_content, $vids, PREG_SET_ORDER ) ) {
795
  foreach ( $vids as $vid ) {
796
  if ( is_array( $vid ) && array_key_exists( 1, $vid ) && false === strpos( trim( $vid[0] ), ' ' ) ) {
797
+ $vid_repla = str_replace( $vid[1], $prep_repla['replace'], $vid[0] );
798
+ $the_content = str_replace( $vid[0], $vid_repla, $the_content );
799
  }
800
  }
801
  }