New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative filepath to local file broken in PDF #5941
Comments
Would you be able to attach a couple of test PDFs to illustrate the problem? It's a matter of when someone gets a few minutes to look at it they don't have to spend them making a test case. ;-) |
We're supposed to handle them correctly (at least, I checked that on local html files linking to other html files): koreader/frontend/apps/reader/modules/readerlink.lua Lines 70 to 72 in f9a57a3
koreader/frontend/apps/reader/modules/readerlink.lua Lines 458 to 472 in f9a57a3
koreader/frontend/apps/reader/modules/readerlink.lua Lines 519 to 560 in f9a57a3
So, might be worth switching to debug mode to see what kind of link string we get from the PDF. |
Works like this (which seems more accurate anyway… does CREngine just say diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua
index 26378f3b..98a405f0 100644
--- a/frontend/apps/reader/modules/readerlink.lua
+++ b/frontend/apps/reader/modules/readerlink.lua
@@ -524,7 +524,7 @@ function ReaderLink:onGotoLink(link, neglect_current_location, allow_footnote_po
end
-- Check if it is a link to a local file
- local linked_filename = link_url:gsub("^file:", "") -- remove local file protocol if any
+ local linked_filename = link_url:gsub("^file://", "") -- remove local file protocol if any
local anchor
if linked_filename:find("?") then -- remove any query string (including any following anchor)
linked_filename, anchor = linked_filename:match("^(.-)(%?.*)$") |
I think it gives what's in the HTML file untouched. That was my text file: <!DOCTYPE html>
<html>
<head>
<style>
p { color: red; text-indent: 1.2em;}
</style>
</head>
<body>
This is some text.<br/>
<a href="http://www.eazeazeaz.com">This is some text</a>.<br/>This is some text.<br/>This is some text.<br/>This is some text.<br/>
This is some text.<br/>
<a href="/">/</a>.<br/>
<a href="etc">etc</a>.<br/>
<a href="file:">file:</a>.<br/>
<a href="/etc/passwd">/etc/passwd</a>.<br/>
<a href="file:/etc/passwd">file:/etc/passwd</a>.<br/>
<a href="/etc/X11/rgb.txt">/etc/X11/rgb.txt</a>.<br/>
<a href="file:/etc/X11/rgb.txt">file://etc/X11/rgb.txt</a>.<br/>
<a href="/tmp/test.txt.txt">/tmp/test.txt.txt</a>.<br/>
<a href="file:/tmp/test.txt.txt">file:/tmp/test.txt.txt</a>.<br/>
<a href="file://tmp/test.txt.txt">file://tmp/test.txt.txt</a>.<br/>
<a href="file:///tmp/test.txt.txt">file:///tmp/test.txt.txt</a>.<br/>
<hr/>
<div class=thisisaDIV style="color: green">
This is some text.<br/>
This is <a href="Wikipedia/test-link2.html">test-link2</a> text.<br/>
This is <a href="Wikipedia/test-link2.html#toto tutu#titi tata">test-link2 with #</a> text.<br/>
This is <a href="Wikipedia/test-link2.html?q=eza&rez=eza#toto tutu#titi tata">test-link2 with ?</a> text.<br/>
This is some text.
</div>
</body>
</html> |
<a href="file:/tmp/test.txt.txt">file:/tmp/test.txt.txt</a>.<br/>
<a href="file://tmp/test.txt.txt">file://tmp/test.txt.txt</a>.<br/> Note that Firefox normalizes these to the correct If Firefox does that then presumably so should we, but for PDF the incorrect varieties are probably less relevant. The pattern you suggested should do the trick for that. |
Only borked ones were supported. The new behavior mimics Firefox. The following incorrect varieties will be treated the same as the correct `file:///tmp/test.txt`. * file:/tmp/test.txt * file://tmp/test.txt Fixes <koreader#5941>. See <koreader#5941 (comment)> for discussion.
Even the 2nd one I'd may be be inclined to see |
Ah, indeed. My bad. https://en.wikipedia.org/wiki/File_URI_scheme |
Only one style was supported. Fixes <#5941>. See <#5941 (comment)> for discussion.
Only one style was supported. Fixes <koreader#5941>. See <koreader#5941 (comment)> for discussion.
Issue
Quite a specific use-case, but currently it seems KOreader only supports absolute file paths for links to other files on the device. If I create a pdf file with a hyperlink to another pdf file within the same folder (using LaTeX hyperref package) giving the relative filepath
./filename.pdf
then other pdf readers I have tried have the correct behaviour of opening filename.pdf if it exists in the folder. However, KOreader gives an error saying it is an invalid link. The link does work in KOreader if I replace it with an absolute file path.This would be a useful feature/fix for me because I would like the same links to work whether I read the pdfs on my laptop or Kobo device.
The text was updated successfully, but these errors were encountered: