Jump to:
| Project: | FlashVideo |
| Version: | 6.x-1.5 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I am using this video tag:
[video: width=250: height=200]
When parsed by _flashvideo_replace_tags, it does not see more than 1 parameter. Because it does not see more than 1 parameter and just matches on height, height and width are not both defined, so the width and height of the video player are not set due to logic in other places that requires them to both be set.
This renders flashvideo useless. I reverted back to 1.5rc4 and everything works fine. I know there was a lot of reworking in the video tag parsing between 1.5r4 and 1.5, just doesn't look like its completely correct. I am running PHP 5.2.9, and I would expect that it would work as thats a pretty recent version.
Here is the output of a print_r($match) inside of the preg_match loop in that function that is showing what it is matching on with this video tag.
Array
(
[0] => Array
(
[0] => [video: width=250: height=200]
[1] => 230
)
[1] => Array
(
[0] =>
[1] => 230
)
[2] => Array
(
[0] => height
[1] => 249
)
[3] => Array
(
[0] => 200
[1] => 256
)
As you can see, its getting the whole tag in, but only parsing the height parameter.
I believe something may be wrong with the way the nested grouping is being expected to also repeat, I didn't think a regex would work that way.
Thanks, Jeremy
Comments
#1
My solution to make 1.5 work is to break up the single regex into 2 separate regex to allow the repetitive group matching. Mostly an inefficient hack, and I suspect a better implementation could be used. But it now works. Basic method is to have the first regex only match and group on the [video] tag and all of its contents. Second regex iterates on just the part of the [video] tag that is not [video, this allowed the regex to group repeatedly via preg_match_all.
Sorry I can't generate a patch... here is the code.
// strip out the beginning tag
$baseparams = str_replace("[$tag","",$match[0][0]);
// then run the repeatable match
$patternparams = '/\s*:\s*([^=]+)=([^:\]]+)/i';
preg_match_all($patternparams, $baseparams, $matchparams);
// Initialize our parameters array.
$params = array();
if(count($matchparams) > 1) {
$numParams = count($matchparams[1]);
for ($i=0;$i<$numParams;$i++) {
$params[$matchparams[1][$i]] = $matchparams[2][$i];
}
}
it completely replaces this code in 1.5 that is at line 2215 and in the function _flashvideo_replace_tags:
// Initialize our parameters array.
$params = array();
$maxi = count($match);
for ($i=2; $i<$maxi; $i=$i+2) {
$params[$match[$i][0]] = $match[$i+1][0];
}
#2
*Subscribing*
This should really be addressed - it's a critical issue!
Not even the notes in the .module file parse correctly (or at all):
(Line 359)
/**
* Populates and returns a FlashVars string.
*
* To allow for custom usage for the FlashVar string, the FlashVideo module has
* put into place a method for creating custom FlashVar strings. You can do this two
* ways; by either specifying it within the FlashVideo Settings where it says "Custom FlashVars"
* which will be used for that node type, or you can be more specific by using the [video] tag
* for each video uploaded to that node using the following schema:
*
* [video: flashvar|param=value]
*
* where "flashvar" indicates that the parameter is a FlashVar followed by a "|"
* and then your FlashVar parameter and value. For example, if I want to set my intro
* image for my video as "intro.jpg", my [video] tag would look like the following:
*
* [video: flashvar|image=intro.jpg]
...
No information within these tag conventions are respected.
Thanks for the temporary fix, jeremy.zerr!
#3
Subscribing. I have the same problem. Does nobody use this module anymore? Is there something better in D6?