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
Well... crap. And here I am about to try and test this on a site with Russian as the default language...
#2
The bug comes from use of single-byte
strposandsubstr_replacefunctions on multi-byte strings.Because there is no multi-byte
substr_replacefunction built in PHP, I included in the patch one that I found in the User Contributed Notes on http://www.php.net/substr_replace.#3
Does this work for non-multi-byte character configurations? Can anyone verify?
#4
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
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
I noticed that I forgot to replace one occurrence of
substr_replace, so here is an update patch.#7
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++.