Errr.. Sorry, didn’t new that the HTML code that i type in here is actually parsed.
Again in Codeblocks:
Example #1:
HTML: "<a href="/relative-link">Relative Link</a>"
PDF: "file:///relative-link"
(Should be http(s)://www.example.tld/relative-link)
Example #2:
HTML: "<a href="https://www.example.tld/worpress/article/?aid=1736&sa=1" title="Document name"><b>Document name</b>, Version</a>
PDF: "file:///<%TEMPDIR>;/<PDF DOCUMENT>.pdf?aid=1736&sa=1"
In this case an absolute URL is given, but is then somehow converted so that the URL that the user called when reading the article (https://www.example.tld/worpress/article/
) is replaced by the PDF document location on local harddrive (file:///<%TEMP%><PDF DOCUMENT>.pdf
)
Hey,
i found a workaround for myself, but if i use it i am unable to update the plugin without override the changes.
The basic idea is to edit the file located in post2pdf-converter/post2pdf-converter-pdf-maker.php and add some “search/replace” routine @line 488 (below shortcode parsing).
Assuming that you have two variables which contains the siteurl (e.g. $siteurl = 'http://www.example.com'
) while the other one holds the referer of the calling page (e.g. `$fullpath = ‘http://www.example.com/cat/my-article’) one can use this code to replace all relative URLs in href-attributes and replace them by absolute links:
preg_replace('/(<a [^>]*href=)"([^"]+)/e', "substr('$2', 0, 4) === 'http' ? '$1' . '\"' . '$2' : substr('$2', 0, 1) === '/' ? '$1' . '\"' . '$siteurl' . '$2' : '$1' . '\"' . '$fullpath' . '/' . '$2'", content);
This line could be made somehow more readable. But i think you get the idea. It basicly checks if the URL given in an href-attribute within an a-tag is
1) absolute
2) relative to current URL
3) reltive to domain
In the first case the link is left as it it, while in the second and third case the link is expanded to an absolute URL.
Hope you can implement a fix soon.
Hi, Coksnuss san
Thank you for your report and idea.
I will fix it in future release.
Hi, Coksnuss san
Please try to re-install Development Version.
I fixed it.
But I can’t reproduct following issue.
HTML: "<a href="https://www.example.tld/worpress/article/?aid=1736&sa=1" title="Document name"><b>Document name</b>, Version</a>
PDF: "file:///<%TEMPDIR>;/<PDF DOCUMENT>.pdf?aid=1736&sa=1"
Thanks again.
For some reason the development version also fixed the issue that you couldn’t reproduce :).