vobject icon indicating copy to clipboard operation
vobject copied to clipboard

Text Property `strtr(): Argument #1 ($string) must be of type string, array given`

Open the-djmaze opened this issue 2 years ago • 2 comments

KDE KAddressBook has <x-crypto><allowed> to select which kind of email encryptions are allowed for the contact.

<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"no" ?>
<vcards xmlns=3D"urn:ietf:params:xml:ns:vcard-4.0">
  <vcard>
    <x-crypto>
      <allowed>
        <text>PGP/INLINE</text>
        <text>PGP/MIME</text>
        <text>S/MIME</text>
        <text>S/MIMEOpaque</text>
      </allowed>
      <signpref>
        <text>Never</text>
      </signpref>
      <encryptpref>
        <text>Always</text>
      </encryptpref>
    </x-crypto>
  </vcard>
</vcards>

When VCard->validate() is called, Sabre\VObject\Property\Text::getRawMimeDirValue() throws warning: strtr(): Argument #1 ($string) must be of type string, array given

https://github.com/sabre-io/vobject/blob/49dbd1bacba784025cc012fd7d908dd87a725914/lib/Property/Text.php#L142 Has an issue because $subItem is an array:

$item = array (
  0 => 
  array (
    'name' => '{urn:ietf:params:xml:ns:vcard-4.0}text',
    'value' => 'PGP/INLINE',
    'attributes' => 
    array (
    ),
  ),
  1 => 
  array (
    'name' => '{urn:ietf:params:xml:ns:vcard-4.0}text',
    'value' => 'PGP/MIME',
    'attributes' => 
    array (
    ),
  ),
  2 => 
  array (
    'name' => '{urn:ietf:params:xml:ns:vcard-4.0}text',
    'value' => 'S/MIME',
    'attributes' => 
    array (
    ),
  ),
  3 => 
  array (
    'name' => '{urn:ietf:params:xml:ns:vcard-4.0}text',
    'value' => 'S/MIMEOpaque',
    'attributes' => 
    array (
    ),
  ),
)

VObject parsed structure in PHP:

            [X-CRYPTO] => Array
                (
                    [0] => Sabre\VObject\Property\Unknown Object
                        (
                            [delimiter] => ,
                            [structuredValues:protected] => Array
                                (
                                    [0] => N
                                    [1] => ADR
                                    [2] => ORG
                                    [3] => GENDER
                                    [4] => CLIENTPIDMAP
                                    [5] => REQUEST-STATUS
                                )

                            [minimumPropertyValues:protected] => Array
                                (
                                    [N] => 5
                                    [ADR] => 7
                                )

                            [name] => X-CRYPTO
                            [group] => 
                            [parameters] => Array
                                (
                                )

                            [value:protected] => Array
                                (
                                    [0] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [name] => {urn:ietf:params:xml:ns:vcard-4.0}text
                                                    [value] => PGP/INLINE
                                                    [attributes] => Array
                                                        (
                                                        )

                                                )

                                            [1] => Array
                                                (
                                                    [name] => {urn:ietf:params:xml:ns:vcard-4.0}text
                                                    [value] => PGP/MIME
                                                    [attributes] => Array
                                                        (
                                                        )

                                                )

                                            [2] => Array
                                                (
                                                    [name] => {urn:ietf:params:xml:ns:vcard-4.0}text
                                                    [value] => S/MIME
                                                    [attributes] => Array
                                                        (
                                                        )

                                                )

                                            [3] => Array
                                                (
                                                    [name] => {urn:ietf:params:xml:ns:vcard-4.0}text
                                                    [value] => S/MIMEOpaque
                                                    [attributes] => Array
                                                        (
                                                        )

                                                )

                                        )

                                    [1] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [name] => {urn:ietf:params:xml:ns:vcard-4.0}text
                                                    [value] => Never
                                                    [attributes] => Array
                                                        (
                                                        )

                                                )

                                        )

                                    [2] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [name] => {urn:ietf:params:xml:ns:vcard-4.0}text
                                                    [value] => Always
                                                    [attributes] => Array
                                                        (
                                                        )

                                                )

                                        )

                                )

the-djmaze avatar Sep 05 '22 09:09 the-djmaze

Above commit is an idea of me to solve this for my needs. I have no idea if this is the correct "hack" way for this library.

the-djmaze avatar Sep 05 '22 20:09 the-djmaze

Here's the vCard structure:

X-KADDRESSBOOK-CRYPTOENCRYPTPREF:alwaysIfPossible
X-KADDRESSBOOK-CRYPTOPROTOPREF:inline openpgp\,openpgp/mime\,any openpgp
X-KADDRESSBOOK-CRYPTOSIGNPREF:askAlways

the-djmaze avatar Sep 08 '22 07:09 the-djmaze