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]
CommentFileSizeAuthor
#7 flash_mb3.patch2 KBmiopa
#6 flash_mb2.patch3.56 KBmiopa
#2 flash_mb.patch4.27 KBmiopa

Comments

dmjossel’s picture

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

miopa’s picture

Status: Active » Needs review
StatusFileSize
new4.27 KB

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.

travist’s picture

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

miopa’s picture

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.

attheshow’s picture

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?

miopa’s picture

StatusFileSize
new3.56 KB

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

miopa’s picture

StatusFileSize
new2 KB

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++.