firefoxfirefox-addonlocal-filesprotocol-handler

Security Error when loading local files in own protocol handler


I'm creating Firefox addon that registers new protocol which should provide HTML to Firefox from file stored on disk (generated by binary exe).

I have problem with images in tags and (probably) css styles that refer to local file. They aren't load properly and I'm getting a message in the errorconsole like this :

Security Error: Content at moz-nullprincipal:{afde522e-6b29-4359-9959-c46c749687f6} may not load or link to file:///E:/xowa_app/user/anonymous/app/img/file/magnify-clip.png.

My protocol flags : nsIProtocolHandler.URI_IS_LOCAL_FILE | nsIProtocolHandler.URI_IS_LOCAL_RESOURCE | nsIProtocolHandler.URI_STD | nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT. (I don't know whether I understand properly MDN reference)

nsIProtocolHandler interface specs need to me that I implement function to creating new channel (MDN) when it is opening URI by the protocol. I create a channel from URI located on disk (html generated by program). The channel has owner property that "grant or deny privileges" and I setted even the owner to system principal who "passes all security checks" (MDN) but the errors are the same.


Solution

  • It seems to that just removing URI_INHERITS_SECURITY_CONTEXT flag (and leaving change owner to system principal) resolves my problem although I don't know when there is need to use this flag.