xoops forums

Roby73

Friend of XOOPS
Posted on: 2015/8/14 6:31
Roby73
Roby73 (Show more)
Friend of XOOPS
Posts: 262
Since: 2011/6/15
#1

Bug /class/textsanitizer/youtube

I include in the news module an youtube video.
I had the problem in the code /class/textsanitizer/youtube/youtube.php
static function decode($url$width$height)     {         
if (!
preg_match("/^http://(www.)?youtube.com/watch?v=(.*)/i"$url$matches)) {             
trigger_error("Not matched: {$url} {$width} {$height}"E_USER_WARNING);              
return 
"";         
}         
$src "http://www.youtube.com/v/" $matches[2];


I modified http to https for resolve.

zyspec

Module Developer
Posted on: 2015/8/15 15:15
zyspec
zyspec (Show more)
Module Developer
Posts: 1042
Since: 2004/9/21
#2

Re: Bug /class/textsanitizer/youtube

Roby73,

Another thing that should be done to fix this is to change the preg_match so either http: or https: will work if passed as the $url variable into the function. Something like:

static function decode($url$width$height)     {          
if (!
preg_match("/^http(s)?://(www.)?youtube.com/watch?v=(.*)/i"$url$matches)) {              
trigger_error("Not matched: {$url} {$width} {$height}"E_USER_WARNING);               
return 
"";          
}          
$src "https://www.youtube.com/v/" $matches[3];

Roby73

Friend of XOOPS
Posted on: 2015/8/15 21:35
Roby73
Roby73 (Show more)
Friend of XOOPS
Posts: 262
Since: 2011/6/15
#3

Re: Bug /class/textsanitizer/youtube

This is better .

Mamba

Moderator
Posted on: 2015/8/16 20:27
Mamba
Mamba (Show more)
Moderator
Posts: 10770
Since: 2004/4/23
#4

Re: Bug /class/textsanitizer/youtube

The "https" issue has been already addressed in the upcoming XOOPS 2.5.8, but for the time being, please follow the code from Zyspec
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Roby73

Friend of XOOPS
Posted on: 2015/8/23 21:59
Roby73
Roby73 (Show more)
Friend of XOOPS
Posts: 262
Since: 2011/6/15
#5

Re: Bug /class/textsanitizer/youtube

This patch does not work always.
In some server (new php version) the code of Zyspec give an error.
To resolve i change only http to https.

Mamba

Moderator
Posted on: 2015/8/24 10:01
Mamba
Mamba (Show more)
Moderator
Posts: 10770
Since: 2004/4/23
#6

Re: Bug /class/textsanitizer/youtube

Try to use this:

Quote:
static function decode($url, $width, $height)
{
if (!preg_match("/^http[s]?:\/\/(www\.)?youtube\.com\/watch\?v=(.*)/i", $url, $matches)) {
trigger_error("Not matched: {$url} {$width} {$height}", E_USER_WARNING);

return "";
}
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Roby73

Friend of XOOPS
Posted on: 2015/8/24 20:56
Roby73
Roby73 (Show more)
Friend of XOOPS
Posts: 262
Since: 2011/6/15
#7

Re: Bug /class/textsanitizer/youtube

Now work fine.
I tried to fix the regular expressions but i made a mistake.