Skip to content
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

Content-Security-Policy of images with GDrive on epub reader wrong #3108

Closed
mudream4869 opened this issue Jul 22, 2024 · 3 comments
Closed

Comments

@mudream4869
Copy link

Describe the bug/problem

The image in epub viewer doesn't show due to Content Security Policy.

Refused to load the stylesheet 'blob:http://localhost:8083/acb1e319-44e0-4e50-a62a-2e8ddd1ea961' because it violates the following Content Security Policy directive: "default-src 'self' 'unsafe-inline' 'unsafe-eval'". Note that 'style-src-elem' was not explicitly set, so 'default-src' is used as a fallback.

Relative: #3060

@OzzieIsaacs
Copy link
Collaborator

Could you please send me the book in question via private email (email address from my profile page). I'd like to reproduce the issue myself

@mudream4869
Copy link
Author

mudream4869 commented Jul 24, 2024

if request.endpoint == "edit-book.show_edit_book" or config.config_use_google_drive:

It seems this bug will appear when google drive API is enabled.

An epub3 sample book: Accessible EPUB 3 can reproduce this bug.

I have a hot-fix and it just works for my conditions, but I'm not sure if its logic is ok.

    if request.endpoint == "edit-book.show_edit_book":
        csp += " *;"
    elif request.endpoint == "web.read_book":
        csp += " blob:; style-src-elem 'self' blob: 'unsafe-inline';"
    elif config.config_use_google_drive:
        csp += " *;"
    else:
        csp += ";"
    csp += " object-src 'none';"

@OzzieIsaacs OzzieIsaacs changed the title Content-Security-Policy of images Content-Security-Policy of images with GDrive on epub reader wrong Jul 24, 2024
OzzieIsaacs added a commit that referenced this issue Jul 25, 2024
Fix csp Header for reader and google drive (#3108)
Testrun
@OzzieIsaacs
Copy link
Collaborator

Please check the newest nightly version, should work now (hopefully without side effects)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants