6.0.0-beta1
7/9/25

[#11014] Contact data damaged when adding contact to address book
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

History
01/28/2016 04:21:24 PM Jan Schneider State ⇒ No Feedback
Version ⇒ Git master
 
01/30/2013 04:58:05 PM Jan Schneider Comment #4 Reply to this comment
A solution might be to allow an optional parameter 'regexp' inside 
the 'parse' settings that would be used instead of the 'format' 
string to parse out the composition fields.
Would that work for your situation?
04/05/2012 09:35:44 AM Jan Schneider Type ⇒ Enhancement
State ⇒ Feedback
Priority ⇒ 1. Low
 
02/22/2012 03:21:02 PM Jan Schneider Comment #3 Reply to this comment
A solution might be to allow an optional parameter 'regexp' inside the 
'parse' settings that would be used instead of the 'format' string to 
parse out the composition fields.
02/22/2012 03:12:59 PM Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
But in this case the problem is to find three substrings separated 
by space(s). explode() should be enough?
No, because that would take away flexibility in the parsing rules. And 
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.
02/20/2012 07:45:54 PM maciej (dot) uhlig (at) us (dot) edu (dot) pl Comment #1
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ Contact data damaged when adding contact to address book
Queue ⇒ Turba
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
Reply to this comment
Summary: Surname or name of contact are possibly damaged when adding
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 #10956 and shown to 
slusarz@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?

Saved Queries