Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1820395
QuotedPrintableTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
3 KB
Subscribers
None
QuotedPrintableTest.php
View Options
<?php
namespace
Sabre\VObject\Parser
;
use
Sabre\VObject\Reader
;
class
QuotedPrintableTest
extends
\PHPUnit_Framework_TestCase
{
function
testReadQuotedPrintableSimple
()
{
$data
=
"BEGIN:VCARD
\r\n
LABEL;ENCODING=QUOTED-PRINTABLE:Aach=65n
\r\n
END:VCARD"
;
$result
=
Reader
::
read
(
$data
);
$this
->
assertInstanceOf
(
'Sabre
\\
VObject
\\
Component'
,
$result
);
$this
->
assertEquals
(
'VCARD'
,
$result
->
name
);
$this
->
assertEquals
(
1
,
count
(
$result
->
children
()));
$this
->
assertEquals
(
"Aachen"
,
$this
->
getPropertyValue
(
$result
->
label
));
}
function
testReadQuotedPrintableNewlineSoft
()
{
$data
=
"BEGIN:VCARD
\r\n
LABEL;ENCODING=QUOTED-PRINTABLE:Aa=
\r\n
ch=
\r\n
en
\r\n
END:VCARD"
;
$result
=
Reader
::
read
(
$data
);
$this
->
assertInstanceOf
(
'Sabre
\\
VObject
\\
Component'
,
$result
);
$this
->
assertEquals
(
'VCARD'
,
$result
->
name
);
$this
->
assertEquals
(
1
,
count
(
$result
->
children
()));
$this
->
assertEquals
(
"Aachen"
,
$this
->
getPropertyValue
(
$result
->
label
));
}
function
testReadQuotedPrintableNewlineHard
()
{
$data
=
"BEGIN:VCARD
\r\n
LABEL;ENCODING=QUOTED-PRINTABLE:Aachen=0D=0A=
\r\n
Germany
\r\n
END:VCARD"
;
$result
=
Reader
::
read
(
$data
);
$this
->
assertInstanceOf
(
'Sabre
\\
VObject
\\
Component'
,
$result
);
$this
->
assertEquals
(
'VCARD'
,
$result
->
name
);
$this
->
assertEquals
(
1
,
count
(
$result
->
children
()));
$this
->
assertEquals
(
"Aachen
\r\n
Germany"
,
$this
->
getPropertyValue
(
$result
->
label
));
}
function
testReadQuotedPrintableCompatibilityMS
()
{
$data
=
"BEGIN:VCARD
\r\n
LABEL;ENCODING=QUOTED-PRINTABLE:Aachen=0D=0A=
\r\n
Deutschland:okay
\r\n
END:VCARD"
;
$result
=
Reader
::
read
(
$data
,
Reader
::
OPTION_FORGIVING
);
$this
->
assertInstanceOf
(
'Sabre
\\
VObject
\\
Component'
,
$result
);
$this
->
assertEquals
(
'VCARD'
,
$result
->
name
);
$this
->
assertEquals
(
1
,
count
(
$result
->
children
()));
$this
->
assertEquals
(
"Aachen
\r\n
Deutschland:okay"
,
$this
->
getPropertyValue
(
$result
->
label
));
}
function
testReadQuotesPrintableCompoundValues
()
{
$data
=
<<<VCF
BEGIN:VCARD
VERSION:2.1
N:Doe;John;;;
FN:John Doe
ADR;WORK;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;;M=C3=BCnster =
Str. 1;M=C3=BCnster;;48143;Deutschland
END:VCARD
VCF;
$result
=
Reader
::
read
(
$data
,
Reader
::
OPTION_FORGIVING
);
$this
->
assertEquals
(
array
(
''
,
''
,
'Münster Str. 1'
,
'Münster'
,
''
,
'48143'
,
'Deutschland'
),
$result
->
ADR
->
getParts
());
}
private
function
getPropertyValue
(
\Sabre\VObject\Property
$property
)
{
return
(
string
)
$property
;
/*
$param = $property['encoding'];
if ($param !== null) {
$encoding = strtoupper((string)$param);
if ($encoding === 'QUOTED-PRINTABLE') {
$value = quoted_printable_decode($value);
} else {
throw new Exception();
}
}
$param = $property['charset'];
if ($param !== null) {
$charset = strtoupper((string)$param);
if ($charset !== 'UTF-8') {
$value = mb_convert_encoding($value, 'UTF-8', $charset);
}
} else {
$value = StringUtil::convertToUTF8($value);
}
return $value;
*/
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Dec 22, 2:33 AM (6 d, 16 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
916535
Default Alt Text
QuotedPrintableTest.php (3 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment