Skip to content

Commit

Permalink
vcard: Fix whitespace handling in line cont's
Browse files Browse the repository at this point in the history
Previously, multiple whitespace characters at the start of a
continuation line would all be dropped, instead of only the first one.

Also,
 - restrict line continuation characters to SPACE and TAB.

Note that, like before, this identifies the CR (`\r`) character with the
empty string, and thereby notably does not require a CRLF (`\r\n`)
sequence (which is mandated by RFCs 2426, 2425) for line termination
(i.e., `\n` suffices).

Fixes: Bug 1 of issue #9593.
  • Loading branch information
respiranto committed Sep 14, 2024
1 parent 6b64eab commit 1fb1758
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions program/lib/Roundcube/rcube_vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public static function rfc2425_fold($val)
private static function vcard_decode($vcard)
{
// Perform RFC2425 line unfolding and split lines
$vcard = preg_replace(["/\r/", "/\n\\s+/"], '', $vcard);
$vcard = str_replace(["\r", "\n ", "\n\t"], '', $vcard);
$lines = explode("\n", $vcard);
$result = [];

Expand Down Expand Up @@ -985,7 +985,7 @@ private static function detect_encoding($string)
// This will for example exclude photos

// Perform RFC2425 line unfolding and split lines
$string = preg_replace(["/\r/", "/\n\\s+/"], '', $string);
$string = str_replace(["\r", "\n ", "\n\t"], '', $string);
$lines = explode("\n", $string);
$string = '';

Expand Down

0 comments on commit 1fb1758

Please sign in to comment.