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
Fix attachments renaming #9672
Fix attachments renaming #9672
Conversation
trasher
commented
Oct 6, 2021
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #9667 #9600 |
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.
Unless I am wrong, if filename does not have a _X
suffix, filename will not be modified, and so it may result in an infinite loop.
@cedric-anne this is a private method, so it cannot be tested directly. I'm not going to write unit tests for that; it would take too much time. |
Fix 89104ec (#9672) solves the problem. I tested using the message Message16335125161734170604.zip. In addition, I created a message with three different attachments, but having the same name without an extension. All three files have been saved, their names are: Ok! Also, I checked a letter in which two screenshots are attached inside the letter, different but with the same file name. As shown in the screenshot, 2 images have been successfully inserted into the message text. All five documents received by mail: In addition, I sent copies of the last 538 messages from the my production system to the mail receiver. No errors were found. Maybe you can suggest additional testing methods? |
So far, I have only checked messages with attached files with file names without an extension. I am correcting and adding a check for file names with an extension. Added a message check that contains two images (screenshots) with different contents, but with the same file name with the extension (image.png). In addition, the files are not just attached, but inserted as links in the html part of the message (tags Sample message Two files with the same file name image.png are saved with different names image.png and image_1.png, the html part of the message is displayed correctly. The file name was changed by adding the suffix "_1" to the base part of the name. |
Maybe you can suggest additional testing methods? |
You have added a variant of a test message with three IDENTICAL attachments. It seems to me that in life there may be more often an option with several attachments having the same file name, but with DIFFERENT contents. I propose a change:
MTIzNDU2Nzg5MDEyMzQ1Njc4OTA=
MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw In your version, the second and third attachments will be discarded with the message "glpiphplog.ERROR: Document_Item::prepareInputForAdd() in /usr/share/glpi/inc/document_item.class.php line 125 Duplicated document item relation" In my version, all three attached files will be saved, my check is more complete. |
Hello @BorisNovg , Thank you very much for your tests and feedbacks!! I'm trying to add your tests cases in our suite, I do not have any extra case to suggest. |
One more small remark. I'm not sure that this is a matter of principle, but I want to note that until now (in release versions 9.5.5 and 9.5.6) when renaming a file a suffix was added starting with "_2". In the proposed version a suffix is added starting with "_1". Probably the old renaming method was more correct and cosmetically more beautiful. Perhaps this will be important for some plugins. Here is a screenshot from the previous version: Here is a screenshot from the version 89104ec Maybe make such a change as shown below? glpi/inc/mailcollector.class.php Line 1597 in 89104ec
$basename .= '_2'; I tested it on two of my messages. There were no errors. |
No problem for me to switch back to |
Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
I noticed that during the control testing these tests were failed with log messages:
As a solution, you are trying to change the test email However, these are most likely erroneous actions, since exactly the same error messages are present in absolutely all successful tests, for example, a month ago: The presence of these messages in the log caused a warning, but not an error when completing the IMAP test: IMHO the test completion error is related to adding a file Perhaps the reason for the error was indicated in the following lines (they are incomprehensible to me):
|
Indeed, those ones are "expected", good catch.
Yes, I saw that one and spent time on it; but I do not understand what the problem is :/ |
Maybe this script output has useful information?
If I understood this script output correctly, the failure occurred precisely in the eighth test (out of 10). |
Yes, that's it... But this test is the one that imports all emails from the inbox; and it does many assertions... The test framework should not fail in any internal class; but it does (maybe a kind of bug on their side, difficult to know). |
Great, many thanks @cedric-anne for tests debug! |