Summary | Contact data damaged when adding contact to address book |
Queue | Turba |
Queue Version | Git master |
Type | Enhancement |
State | No Feedback |
Priority | 1. Low |
Owners | |
Requester | maciej.uhlig (at) us (dot) edu (dot) pl |
Created | 02/20/2012 (4888 days ago) |
Due | |
Updated | 01/28/2016 (3450 days ago) |
Assigned | 02/22/2012 (4886 days ago) |
Resolved | 01/28/2016 (3450 days ago) |
Milestone | |
Patch | No |
Version ⇒ Git master
the 'parse' settings that would be used instead of the 'format'
string to parse out the composition fields.
State ⇒ Feedback
Priority ⇒ 1. Low
'parse' settings that would be used instead of the 'format' string to
parse out the composition fields.
State ⇒ Feedback
by space(s). explode() should be enough?
we are using the same strings for formatting and parsing composite
strings. The formatting rules can be specified arbitrarily, whitespace
splitting is not suffiecient. sscanf() is the only available
counterpart method to printf formatting. And we probably don't want to
implement sscanf() in PHP.
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ Contact data damaged when adding contact to address book
Queue ⇒ Turba
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
contact to address book in case the data is UTF-8 encoded. A part of
multibyte character in surname or name is sometimes treated as a
whitespace when sscanf() is called.
Analysis: There is sscanf() function used in /turba/lib/Driver.php:
$splitval = sscanf($val, $parse['format']);
$var can be a multibyte string (UTF-8 encoded).
sscanf(), as a PHP String function, doesn't handle multibyte encodings
such as UTF-8.
So, instead of sscanf(), another way of composite fields computing
should be used.
Please note 1: PHP manual says: sscanf() function is not locale-aware.
This is not true. PHP's sscanf() uses isspace() system function call
which is locale-aware. Moreover, isspace() works as expected only for
alphanumeric characters and symbols. The results of isspace() on other
than these bytes of unsigned char type is unpredictable in general.
Therefore composite name computing with sscanf() may or may not
succeed, and eventually success is not the proof of code correctness.
Please note 2: this was reported with
Ticket #10956and shown toslusarz@horde.org who wasn't able to reproduce this issue. IMHO the
ability to reproduce the issue depends on subtle operating system
details (i.e. on isspace() implementation).
Please note 3: So, this could be in fact Solaris (not Horde) issue
(doesn't happen under Ubuntu Linux for instance). Solaris isspace() is
badly damaged. However you shouldn't use sscanf() there because data
can be multibyte. But there is no similar multibyte function in PHP. I
think PHP needs something like swscanf(). Maybe Multibyte String or
intl functions could be used.
But in this case the problem is to find three substrings separated by
space(s). explode() should be enough?