Video tag doesn't work after more than 5 cyrillic letters in the body

miopa - May 4, 2009 - 23:03
Project:FlashVideo
Version:6.x-1.5-rc2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

This is kind of bizarre.

The self referencing [video] tag works well, but when used with node or index parameters, it displays "video not available". The bug happens only if the tag is preceded with more than 5 Cyrillic letters.

This works:

Some latin text
[video:node=100:index=0]

This falis:

Some измешан text
[video:node=100:index=0]

This works:

Некој miksed text
[video:node=100:index=0]

#1

dmjossel - May 20, 2009 - 06:58

Well... crap. And here I am about to try and test this on a site with Russian as the default language...

#2

miopa - May 31, 2009 - 17:01
Status:active» needs review

The bug comes from use of single-byte strpos and substr_replace functions on multi-byte strings.

Because there is no multi-byte substr_replace function built in PHP, I included in the patch one that I found in the User Contributed Notes on http://www.php.net/substr_replace.

AttachmentSize
flash_mb.patch 4.27 KB

#3

travist - June 3, 2009 - 18:37

Does this work for non-multi-byte character configurations? Can anyone verify?

#4

miopa - June 4, 2009 - 13:59

It should work, the configuration is irrelevant, the affected functions apply to the body text. But i don't have any non utf-8 installation to check.

#5

attheshow - June 6, 2009 - 22:38

At first glance, this looks like a fairly lengthy function just to do string replacement. Is there really no existing method of doing this without maintaining our own custom function for it?

#6

miopa - June 10, 2009 - 00:21

I noticed that I forgot to replace one occurrence of substr_replace, so here is an update patch.

AttachmentSize
flash_mb2.patch 3.56 KB

#7

miopa - June 17, 2009 - 03:50

I've analyzed the code and found a way to fix it without the added function. The thing is, I'm not sure if it's worse to maintain one extra function or this mash-up of single-byte and multi-byte string pointers that brings to memory the long forgotten horrors of C++.

AttachmentSize
flash_mb3.patch 2 KB
 
 

Drupal is a registered trademark of Dries Buytaert.