Projects
Kolab:16:Testing
php-sabre-vobject
vobject_encoding_performance.patch
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File vobject_encoding_performance.patch of Package php-sabre-vobject
diff --git a/lib/Property.php b/lib/Property.php index 73686bc..efa17bc 100644 --- a/lib/Property.php +++ b/lib/Property.php @@ -241,19 +241,18 @@ abstract class Property extends Node { $str.=':' . $this->getRawMimeDirValue(); - $out = ''; - while(strlen($str)>0) { - if (strlen($str)>75) { - $out.= mb_strcut($str,0,75,'utf-8') . "\r\n"; - $str = ' ' . mb_strcut($str,75,strlen($str),'utf-8'); - } else { - $out.=$str . "\r\n"; - $str=''; - break; - } - } + $str = preg_replace( + '/( + (?:^.)? # 1 additional byte in first line because of missing single space (see next line) + .{1,74} # max 75 bytes per line (1 byte is used for a single space added after every CRLF) + (?![\x80-\xbf]) # prevent splitting multibyte characters + )/x', + "$1\r\n ", + $str + ); - return $out; + // remove single space after last CRLF + return \substr($str, 0, -1); } diff --git a/lib/Property/Text.php b/lib/Property/Text.php index ffd4c4b..30f5e38 100644 --- a/lib/Property/Text.php +++ b/lib/Property/Text.php @@ -270,20 +270,19 @@ class Text extends Property { } else { $str.=':' . $val; - $out = ''; - while(strlen($str)>0) { - if (strlen($str)>75) { - $out.= mb_strcut($str,0,75,'utf-8') . "\r\n"; - $str = ' ' . mb_strcut($str,75,strlen($str),'utf-8'); - } else { - $out.=$str . "\r\n"; - $str=''; - break; - } - } - - return $out; + $str = \preg_replace( + '/( + (?:^.)? # 1 additional byte in first line because of missing single space (see next line) + .{1,74} # max 75 bytes per line (1 byte is used for a single space added after every CRLF) + (?![\x80-\xbf]) # prevent splitting multibyte characters + )/x', + "$1\r\n ", + $str + ); + + // remove single space after last CRLF + return \substr($str, 0, -1); }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.