Skip to content

Fix substr on unicode string#409

Open
Seb-C wants to merge 1 commit intofuel:1.9/developfrom
Seb-C:mainUpstream/fix/observerTypingMultiByte
Open

Fix substr on unicode string#409
Seb-C wants to merge 1 commit intofuel:1.9/developfrom
Seb-C:mainUpstream/fix/observerTypingMultiByte

Conversation

@Seb-C
Copy link

@Seb-C Seb-C commented Jun 21, 2017

This replaces substr by mb_substr.

My specific case happened with a varchar(250) field, and a string that was longer. The 250th and 251th bytes of the string were an UTF-8 non-breakable space (0xC2A0).

Since C2 is a control character that can't exist alone, this made everything using this string crash thereafter (including debugging tools).

@WanWizard
Copy link
Member

That code will fail if mbstring isn't loaded. Ideally, this should use \Str::truncate(), which is multibyte aware.

I think this needs to be looked at in more broader terms, quite a bit of the Fuel was written when overloading string functions was the norm, which isn't the case anymore, and is even deprecated as of PHP 7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants