Can only display first video, index parameter appears to be ignored

origo - August 25, 2009 - 11:04
Project:FlashVideo
Version:6.x-1.5-rc4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I'm having a problem displaying two videos in the same node. Both videos converted OK, and both the generated flv and jpg files (four files in all) are attached to the node. I try to display both videos using the following:

[video: index=0]
[video: index=1]

However both of the statements display the first video. I've tried different values for the index parameter, but I always see just the first video.

#1

origo - September 22, 2009 - 10:01

I tracked down the problem. Basically it's a Unicode programming error. The problem occurs while parsing a [video] tag's parameters, when the node's body is encoded in UTF-8 and contains multibyte characters.

Specifically, the functions _flashvideo_replace_tags and _flashvideo_parse_params use a combination of strpos, explode, substr_replace (not Unicode aware) and drupal_strlen, drupal_substr (Unicode aware). The position found by strpos is incorrect when passed to drupal_substr, which causes the parameter parsing to fail. (Also things like incrementing a position by 1 may be wrong if the current character is multibyte.)

The solution should be to make sure all string functions are Unicode aware. I'm not sure what the best way to do that is, so I hope someone else more knowledgeable in PHP can fix this.

#2

origo - September 22, 2009 - 10:43
Version:6.x-1.5-rc3» 6.x-1.5-rc4

#3

origo - October 14, 2009 - 23:32
Status:active» needs review

I made an attempt to fix this issue using regular expression matching (inspired by the code in the Inline module). Here's a patch that works for me.

AttachmentSize
flashvideo-unicode.patch 6.36 KB

#4

travist - October 21, 2009 - 01:06
Status:needs review» fixed

Great patch. I just committed this to the latest version. It will be in the version 1.5 release.

Thanks for your efforts.

#5

System Message - November 4, 2009 - 01:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.