Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

can not create header object from certain inputs #64

Closed
glensc opened this issue Feb 9, 2016 · 8 comments
Closed

can not create header object from certain inputs #64

glensc opened this issue Feb 9, 2016 · 8 comments
Assignees
Labels

Comments

@glensc
Copy link
Contributor

glensc commented Feb 9, 2016

When trying to load raw (QP encoded, etc) headers with:

Zend\Mail\Headers::fromString($headerString);

I came up to a problem that iconv_mime_encode can not be used reliably to validate if header can be encoded

for example (the value must be exactly like that):

        $name = 'Subject';
        $value = "[#77675] New Issue:xxxxxxxxx xxxxxxx xxxxxxxx xxxxxxxxxxxxx xxxxxxxxxx xxxxxxxx, tähtaeg xx.xx, xxxx";
        $header = new GenericHeader($name, $value);

the above code breaks at HeaderWrap::canBeEncoded when underlying iconv_mime_encode attempts to wordwrap the string and fails as it needs to wrap at middle of character or something:

iconv_mime_encode(): Unknown error (7)

which results false as return value and InvalidArgumentException later

The header will be encoded ok if the $value is lengthened or shortened even one byte before 76th character.

glensc added a commit to eventum/eventum that referenced this issue Feb 9, 2016
@glensc
Copy link
Contributor Author

glensc commented Feb 9, 2016

problem can be mitigated by specifying long enough line-length option.

i've solved this in the past by calculating what the length may be. but current zend code doesn't even have charset parameters, so it could be anything whatever is current php version and php.ini settings.

so, perhaps hardcode UTF-8 in that specific method and solve it similar way? i'll send PR (with test included) when i get some feedback.

also i'm interested having this on 2.4 branch as well, i read LTS-WORKFLOW and seems the PR should be sent to zf2 repo for that? or maintainers will backport themselves? (the differences 2.4 vs 2.5 are rather in-existent, some array syntax changes only)

@glensc
Copy link
Contributor Author

glensc commented Feb 9, 2016

alternative would be to split the $value on spaces and try to encode each component, as say the comments ([1], [2]) on php.net for the function.

glensc added a commit to eventum/zend-mail that referenced this issue Feb 10, 2016
glensc added a commit to eventum/zend-mail that referenced this issue Feb 15, 2016
backport for 2.4

Conflicts:
	src/Header/HeaderWrap.php
@glensc
Copy link
Contributor Author

glensc commented Mar 10, 2016

hallo?

glensc added a commit to pld-linux/php-ZendFramework that referenced this issue Mar 10, 2016
@smazurov
Copy link

same issue as #33? we ran into this ourselves.

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2016

looks same to me

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2016

this case i even have bugfix, but no maintainer bothered to reply here, so never fired off the pull request

the branch itself is here:
master...glensc:issue-64

@ezimuel
Copy link
Contributor

ezimuel commented Mar 25, 2016

@glensc if you want to submit a PR for this issue it will be awesome! I just merged yours #69 and #61. Sorry again for the delay of my reply :(

@weierophinney
Copy link
Member

i'm interested having this on 2.4 branch as well, i read LTS-WORKFLOW and seems the PR should be sent to zf2 repo for that? or maintainers will backport themselves?

No; we determine if a patch is a candidate, and backport it ourselves, as we have a very specific workflow for that.

Right now, we're very conservative in what we backport, as the process is somewhat time-consuming, as well as brittle. Typical candidates are security fixes, and fixes for BC breaks introduced between 2.3 and 2.4. As such, this does not qualify.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants