TL;DR WebKit, an Apple framework which DT relies on to display HTML-based files, has a safety feature that prevents web pages from accessing local resources. The URL property in DT is used to determine whether the document should be treated as a “web” page.
I was testing my own web clipper when I found this weird behavior in DT.
We have an HTML document, which contains link(s) to external CSS stylesheet(s) inside the local file system, in DT. The issue is with the URL property of the document in the right-side inspector panel.
An example HTML document is given – use your own CSS file path in the <link> tag. The behavior can be recreated by adding a CSS link tag to any HTML document I have.
example.zip (10.8 KB)
a) If the URL property is set to anything containing
://, e.g. https://www.google.com, the external CSS stylesheet(s) will not be loaded when viewing the document. Upon opening the document, a loading progress bar will be shown briefly at the top of the window, despite the document not containing anything that requests content from a web location.
b) If the URL property is blank, or set to a string that is not a URL (e.g. “document”), the external CSS stylesheet(s) will be recognized, and the document displayed correctly. No loading progress bar is shown; the HTML is rendered in an instant.
c) If I use “open with” to open the document in Safari, it is always displayed correctly, no matter the value of the URL property. This proves the validity of the HTML source code.
It’s not the end of the story, though. If I try converting the HTML document into Webarchive, the result depends on whether the URL property of the HTML document is set at the time of conversion.
d) Convert the HTML document in state a), i.e. with a legitimate URL property. Judging from the file size, the linked CSS stylesheet(s) is not embedded in the conversion. No matter what I do (removing the URL property, or messing with the HTML source) to the resulting Webarchive document, it will never load any external CSS.
e) Convert the HTML document in state b), i.e. with a blank or illegitimate URL property. The CSS stylesheet(s) is embedded and loaded correctly upon viewing, and everything is just fine in the resulting Webarchive document. I can change the URL property of the Webarchive to anything, but it will revert to “file:///” on random occasions, as I had reported to Jim in an email support ticket some time ago.
I don’t know whether this is intentional behavior or not, but it certainly looks like a bug to my non-programmer eyes. There is indeed an impact on my workflow; Many of my older Webarchives cannot be re-styled seemingly for this reason; And I have to avoid using the built-in URL property in my web clipping workflow for the time being.
Would love to know if there are solution and/or possibly bug fixes.
Thanks in advance.
DEVONthink Pro 3.9.4, M1 Mac running macOS 14.0