I finally gave up using Sunmaler 2, hoping that the 6.x-1 branch is more mature

Yet I am hit by the same issue than in 6.x-2
http://drupal.org/node/1367526

I changed in sunmailer.xml.inc around line 110

$value = preg_replace('|href="/|', "href=\"$base_root/", $value); // Make all URLs absolute.
by
$value = preg_replace('#(src|href)=(["\'])/#', "$1=$2$base_root/", $value); // Make all URLs absolute.

This made CCK fields working fine, showing images properly.
However, images in node body (edited with CKeditor) are still broken, the links stay relatve.
I tried Pathologic, but it did not help.

Thanks for help.

Comments

jvieille’s picture

Bellow an example of the xml generateed.
Images in teaser are not made absolute, while the File Framework CCK field is OK
By the way, I do not understand why the teaser link contents "/sites/see.shareontheweb.com/files/" while the cck field gives a much shorter link - both working.
For example
Image in body link
http://web2.see.asso.fr/sites/see.shareontheweb.com/files/editorimages/E...
Image in FF CCK field
http://web2.see.asso.fr/bitcache/ec338239f51a870c69ea61895698eaade458e7f...
Both /bitcahce and /editorimages are under the /file directory of the site (multiinstall)
This link does not work:
http://web2.see.asso.fr/sites/editorimages/ERTS2012.jpg

Anyway, the code fix worked well with the 6.x-2 version but not completely with 6.x-1

<teaser>
<![CDATA[
<div>
 <center>
 <div class="rteleft">
 <img alt="" src="/sites/see.shareontheweb.com/files/editorimages/ERTS2012.jpg" style="width: 600px; height: 192px; " /></div>
 <div class="rteleft">
 <strong>Major Topics of Interest</strong></div>
 </center>
 <p>
 - Embedded computing platforms and network systems: Distributed architectures, Multi-core/ many core platforms, FPGA, Network embedded systems, Operating systems and executive services, Middleware, Virtualization, Services oriented platforms, Energy management, Innovative architectures.
]]>
</teaser>
...
<field_revue_edition_couverture_value>
<![CDATA[
<img width="84" height="120" src="http://web2.see.asso.fr/bitcache/ec338239f51a870c69ea61895698eaade458e7ff?vid=2609&disposition=inline">
]]>
</field_revue_edition_couverture_value>

I also tried this code
$value = preg_replace('#(src|href)=(["\'])/#', "$1=$2$base_url/", $value);
replacing $base_root by $base_url
same result

jvieille’s picture

Title: Relative paths are not converted in messages for "src" tags » Relative paths are not converted in messages
Status: Active » Needs review

I found the problem.

The place I put the code was only intended to correct links in filelds. Actually, it the function sunmailer_get_section_nodes() was never called in any situation during my tests.

I changed the function

function sunmailer_transform_xml($xml, $format) {
  // Load XSL.
  $path = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $format['fid']));
  $doc = new DOMDocument();
  $doc->load($path, LIBXML_NOCDATA);
  $xslt = new XSLTProcessor();
  $xslt->importStyleSheet($doc);
  // Transform XML, do some extra processing for text formats.
  $newsletter = $xslt->transformToXML($xml);
  if (!$format['html']) {
    $newsletter = strip_tags($newsletter);
    $newsletter = html_entity_decode($newsletter, ENT_COMPAT, 'UTF-8');
  }
  return $newsletter;
}

to

function sunmailer_transform_xml($xml, $format) {
  // Load XSL.
  $path = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $format['fid']));
  $doc = new DOMDocument();
  $doc->load($path, LIBXML_NOCDATA);
  $xslt = new XSLTProcessor();
  $xslt->importStyleSheet($doc);
  // Transform XML, do some extra processing for text formats.
  $newsletter = $xslt->transformToXML($xml);
+  // makes all URL absoute.
+   global $base_url;
+   $newsletter = preg_replace('#(src|href)=(["\'])/#', "$1=$2$base_url/", $newsletter);
  if (!$format['html']) {
    $newsletter = strip_tags($newsletter);
    $newsletter = html_entity_decode($newsletter, ENT_COMPAT, 'UTF-8');
  }
  return $newsletter;
}

May be some further clean up is needed as apparently some functions are not in use (at least sunmailer_get_section_nodes).

Thanks for updating the module.

Mike Wacker’s picture

Status: Needs review » Closed (duplicate)

Re-opening #1367526: Relative paths are not converted in messages to port the patch downstream to 6.x-1.x-dev.