Skip to content

Embed file are not catched #97

Closed
Closed

Description

@matraux

Version: 3.1

Bug Description

Embed files (images) <img src=".....> are not matched/replaced correctly in Message::setHtmlBody().

Steps To Reproduce

$html = '<img src="C:\Users\FRANTA\projects\Project-X\temp\content\con33C8.svg">';
Message::setHtmlBody($html, '');

will produce:

<img src="C:\Users\FRANTA\projects\Project-X\temp\content\con33C8.svg">

instead of

<img src="cid:xyyrj49su6@localhost">

Expected Behavior

<img src="C:\Users\FRANTA\projects\Project-X\temp\content\con33C8.svg"> converted to <img src="cid:xyyrj49su6@localhost">

Possible Solution

Modify regex in Message::setHtmlBody()
Patter <img[^<>]*\s src\s*=\s* will not catch path contains colons : or spaces .

For images in different folders i can not use param $basePath
Example of used images in html body:
C:\Users\FRANTA\projects\Project-X\temp\content\con33C8.svg
C:\Users\FRANTA\projects\Project-X\app\some folders with spaces\xxxx.jpg
./another folder in root/sub folder/yyyy.png

Activity

  1. dg commented on Apr 23, 2026

    @dg
    Member

    Fixed in f7817b5 — spaces in quoted src="…" and url('…') now work.

    I will not support absolute Windows paths (C:\…). Distinguishing them from URL schemes (http:, cid:, etc.) requires either sacrificing lookahead accuracy or special code for platform-specific parsing, which is beyond the scope of this library. Recommended solution: pass local paths via the $basePath argument or use addEmbeddedFile() manually and reference them via cid:.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions