-
Notifications
You must be signed in to change notification settings - Fork 100
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
Urlize mode bug fixes #840
Conversation
All remarks made in PR #830 are included in the current PR. |
…omment)): Improving consistency of group and user definition in the Sympa::Constants stud.
I think simply recursive urlization of subparts is not always appropriate. We would be better to consider more precise cases where the subparts are treated as "attachment":
Thus, IMO only multipart/mixed may be modified recursively (with restrictions described in above) to "urlize" messages, and all others can be "urlized" by its own (if it is not treated as "text") or be intact (if it is treated as "text" or it is smaller than |
Great review @ikedas ! |
Okie dokie... I had a look and I still have a problem with nested multiparts. Apple Mail sometimes sends emails with attachments within multipart/alternative messages. I think this is wrong because it makes no sense to put the attachments within an alternative part, however it is a fact. I'd like to simply ignore such misbehaviours but end users will probably consider it is Sympa's fault is urlize mode does not work. I'd the like to consider multipart/related and multipart/alternative as potential attachments bearers. That would lead to the following (changes to your version are in bold font):
|
OK, I have implemented what we discussed. A slight change : I urlize sub-parts of multipart/alternative, whichever they are, bu only one level below the message top level part. That means that if they contains anything other than valid text, it will be urlized. That leaves a chance to catch a multipart/mixed inside, but we won't go further. This is not satisfactory yet, though it works well with the test files. It still needs working. I have reorganized the test files to make their usage more explicit. |
OK, now it does exactly what I wanted. Only going to urlize sub parts of a multipart/related if it is a multipart/mixed. |
1- message text was treated as attachment and remained on the server as either "msg.0.bin" or "msg.0.txt" files. Fixed by testing the part type before urlizing it. 2- some special characters in message id led to the attachment to be considered missing by Sympa. I had to refactor the code a bit to allow urlizing of nested multiparts. The detail of urlization treatment is as follows: 1- any multipart/mixed message part will be analyzed to look for urlizable parts, 2- any mulitpart/related message part will be be analyzed to look for multiârt/mixed sub parts, 3- within the multipart/mixed parts, any text/* part whose "Content-Disposition" header is not "attachment" and has a correct Content-Type.charset value is kept untouched, 4- any other subpart is kept on the server an replaced by a download link.
- t/Message.t, - t/samples/ contains six different messages for testing urlize, - t/data/ now contains a test list configuration file.
…onstants because most of them are needed when using Sympa libraries. Specifying the sources 'default' directory for 'DEFAULTDIR' constant to allow access to distributed templates.
OK, I squashed the commits to keep only four commits, combining the code modifications we compromised over. It should be easier to understand fr future developers. |
…attr()' and, therefore, a regular expression by 'eq'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I don't have comments any more.
Actually, I still found some cases in production, just today, that don't come out of urlization as expected. Regards, |
…g a multipart/alternative; In that case, with the current code the multipart/related was urlized as a 'msg.0.bin' attachment, which was wrong. Fixing this behaviour by: 1- allowing to go down two levels of multiparts 2- preventing any urlization if the part is not included in a 'multipart/mixed' parent to prevent urlizing the content of multipart/related or multipart/alternative.
OK, now that seems right. I had to go one level further in the message architecture but I added an explicit rule in _urlize_one_part that will prevent urlization to occur when the parent part is not a multipart/mixed. |
I merged. Thanks @dverdin ! |
Thanks @ikedas ! |
Fixing bugs in urlize mode :
1- message text was treated as attachment and remained on the server as either "msg.0.bin" or "msg.0.txt" files. Fixed by testing the part type before urlizing it.
2- some special characters in message id led to the attachment to be considered missing by Sympa.
I also introduce a test file for Message.t, testing only urlization. this test is set in travis and the test succeeds. Note that commits 065312d and fcadbac are related to travis. The first one to enable the test, the second one to have Sympa::Constants without running make.