RoundCube Webmail
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.1 KiB

Check if attachment is actually(!) referred to (#9585) * Check if "inline" msg part is actually referred to If there's no reference to it in a sibling HTML part then we handle it as a classic attachment (which is shown as downloadable). * Fetch all msg headers also for images to always get Content-Location Previously all headers were only fetched for message/rfc822, or if the Content-Type's "name" parameter was set, or if a Content-ID was set. The RFC doesn't require neither the "name" parameter nor a Content-ID for using Content-Location, though, so we shouldn't depend on those. Instead now all headers are also fetched if the main part of the Content-Type is "image", to catch more cases. * Parse HTML for references only on demand * Typos and comment formatting * Don't skip test anymore We want it tested! * More MR tests with images * Remove early special handling for "inline" images We decide later, which attachment is considered "inline" and which isn't. * Remove early resolving of references in TNEF parts * Testing message rendering of TNEF emails * Don't use image disposition, it's unreliable * Split adding raw parts and attachments * Fix renaming variable * Rename file to make its test be run * Remove outdated script * Annotate test cases with GitHub issue numbers * Fix test case class name * remove comment * Test inline image message rendering * Rename test file to reflect cases better * Reduce image used in test email It doesn't change much, but there's also no sense in decoding big images that we don't use. * Remove unused variable initialisation
6 months ago
  1. <?php
  2. namespace Tests\MessageRendering;
  3. /**
  4. * Test class to test "interesting" messages.
  5. */
  6. class SingleAttachedImageNoTextTest extends MessageRenderingTestCase
  7. {
  8. /**
  9. * Test that of a multipart/mixed message which contains only one
  10. * image, that image is shown. (GitHub issue #9443)
  11. */
  12. public function testShowMultipartMixedSingleImageToo()
  13. {
  14. $domxpath = $this->runAndGetHtmlOutputDomxpath('XXXXXXXXXXXXX@mx01.lytzenitmail.dk');
  15. $this->assertSame('Not OK', $this->getScrubbedSubject($domxpath));
  16. $attchNames = $domxpath->query('//span[@class="attachment-name"]');
  17. $this->assertCount(1, $attchNames, 'Attachments');
  18. $this->assertStringStartsWith('Resized_20240427_200026(1).jpeg', $attchNames[0]->textContent);
  19. }
  20. /**
  21. * Test that an image, that has a Content-ID, which is not accompanied by
  22. * an HTML part (and thus is not referred to), is shown as attachment.
  23. * (GitHub issue #9565)
  24. */
  25. public function testShowUnreferredToImagesWithContentId()
  26. {
  27. $domxpath = $this->runAndGetHtmlOutputDomxpath('yyy@mail.gmail.com');
  28. $this->assertSame('test', $this->getScrubbedSubject($domxpath));
  29. $attchNames = $domxpath->query('//span[@class="attachment-name"]');
  30. $this->assertCount(1, $attchNames, 'Attachments');
  31. $this->assertStringStartsWith('тест.jpg', $attchNames[0]->textContent);
  32. }
  33. /**
  34. * Test that an image, that has a Content-ID, but is not referred to in the
  35. * accompanying HTML-part, is shown as attachment. (GitHub issue #9685)
  36. */
  37. public function testShowUnreferredToImagesWithContentIdInMultipartAlternative()
  38. {
  39. $domxpath = $this->runAndGetHtmlOutputDomxpath('2ef37d1124655807449f5e405cdd4834b79fb026@example.net');
  40. $this->assertSame('Multipart/alternative with attached but unreferenced image', $this->getScrubbedSubject($domxpath));
  41. $attchNames = $domxpath->query('//span[@class="attachment-name"]');
  42. $this->assertCount(1, $attchNames, 'Attachments');
  43. $this->assertStringStartsWith('Stg Aiki - SB - 22-23 Fév 2025.jpg', $attchNames[0]->textContent);
  44. }
  45. }