Blob Blame History Raw
commit 2f79c6938c6d969f3d4ebc9ed0f2648668434502
Author: albert-github <albert.tests@gmail.com>
Date:   Sat Jan 4 13:24:16 2020 +0100

    issue #7477 Broken urls in the xml output
    
    Made code analogous to HTML code.
    Also the doxygen internal tests suffered from this problem.

diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp
index 409c2fe6..1e6becbe 100644
--- a/src/xmldocvisitor.cpp
+++ b/src/xmldocvisitor.cpp
@@ -824,18 +824,22 @@ void XmlDocVisitor::visitPre(DocImage *img)
 {
   if (m_hide) return;
 
-  QCString baseName=img->name();
-  int i;
-  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
+  QCString url = img->url();
+  QCString baseName;
+  if (url.isEmpty())
   {
-    baseName=baseName.right(baseName.length()-i-1);
+    baseName = img->relPath()+img->name();
+  }
+  else
+  {
+    baseName = correctURL(url,img->relPath());
   }
   visitPreStart(m_t, "image", FALSE, this, img->children(), baseName, TRUE, img->type(), img->width(), img->height(), img ->isInlineImage());
 
   // copy the image to the output dir
   FileDef *fd;
   bool ambig;
-  if ((fd=findFileDef(Doxygen::imageNameDict,img->name(),ambig)))
+  if (url.isEmpty() && (fd=findFileDef(Doxygen::imageNameDict,img->name(),ambig)))
   {
     QFile inImage(fd->absFilePath());
     QFile outImage(Config_getString(XML_OUTPUT)+"/"+baseName.data());
diff --git a/testing/031/indexpage.xml b/testing/031/indexpage.xml
index 2d74510a..eaf374b6 100644
--- a/testing/031/indexpage.xml
+++ b/testing/031/indexpage.xml
@@ -11,42 +11,42 @@
  <image type="docbook" name="sample.png"/>
  More text.</para>
       <para>SVG image with caption:<linebreak/>
-<image type="html" name="license-MIT-brightgreen.svg">A caption</image>
+<image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.svg">A caption</image>
 </para>
       <para>PNG image with caption:<linebreak/>
-<image type="html" name="license-MIT-brightgreen.png">A caption</image>
+<image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.png">A caption</image>
 </para>
       <para>SVG image without caption:<linebreak/>
-<image type="html" name="license-MIT-brightgreen.svg"/>
+<image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.svg"/>
 </para>
       <para>PNG image without caption:<linebreak/>
-<image type="html" name="license-MIT-brightgreen.png"/>
+<image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.png"/>
 </para>
       <para>Inline SVG image with caption:<linebreak/>
-This image is inline <image type="html" name="license-MIT-brightgreen.svg" inline="yes">MIT license</image>
+This image is inline <image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.svg" inline="yes">MIT license</image>
  within the text.</para>
       <para>Inline PNG image with caption:<linebreak/>
-This image is inline <image type="html" name="license-MIT-brightgreen.png" inline="yes">MIT license</image>
+This image is inline <image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.png" inline="yes">MIT license</image>
  within the text.</para>
       <para>Markdown style linked SVG image:<linebreak/>
-<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.svg" inline="yes"/></ulink></para>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.svg" inline="yes"/></ulink></para>
       <para>Markdown style linked PNG image:<linebreak/>
-<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.png" inline="yes"/></ulink></para>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.png" inline="yes"/></ulink></para>
       <para>HTML style linked SVG image:<linebreak/>
-<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.svg" inline="yes"/></ulink></para>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.svg" inline="yes"/></ulink></para>
       <para>HTML style linked PNG image:<linebreak/>
-<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.png" inline="yes"/></ulink></para>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.png" inline="yes"/></ulink></para>
       <para>HTML style unlinked SVG image:<linebreak/>
-<image type="html" name="license-MIT-brightgreen.svg" inline="yes"/>
+<image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.svg" inline="yes"/>
 </para>
       <para>HTML style unlinked PNG image:<linebreak/>
-<image type="html" name="license-MIT-brightgreen.png" inline="yes"/>
+<image type="html" name="http://img.shields.io/badge/license-MIT-brightgreen.png" inline="yes"/>
 </para>
       <para>Some markdown image tests<linebreak/>
-<image type="html" name="docs-Doxygen-blue.svg?foo&amp;bar" inline="yes"/>
+<image type="html" name="https://img.shields.io/badge/docs-Doxygen-blue.svg?foo&amp;bar" inline="yes"/>
  <ulink url="http://www.doxygen.nl?foo&amp;bar">Some normal link</ulink></para>
       <para>
-        <image type="html" name="docs-Doxygen-blue.svg?foo&amp;bar" inline="yes"/>
+        <image type="html" name="https://img.shields.io/badge/docs-Doxygen-blue.svg?foo&amp;bar" inline="yes"/>
         <ulink url="http://www.doxygen.nl?foo&amp;bar">Some normal link</ulink>
       </para>
     </detaileddescription>