Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
the-djmaze opened this issue Sep 5, 2022 · 2 comments

Comments

@the-djmaze
Copy link

the-djmaze commented Sep 5, 2022

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

foreach ($item as &$subItem) {

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 pushed a commit to the-djmaze/snappymail that referenced this issue Sep 5, 2022
@the-djmaze
Copy link
Author

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
Copy link
Author

Here's the vCard structure:

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

the-djmaze pushed a commit to the-djmaze/sabre-vobject that referenced this issue Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant