当前位置:首页 > 电脑知识

Calibre-Web修复跨域问题

canca5个月前 (01-20)电脑知识299
  1. 修改D:\calibre-web-master\cps\web.py文件

    原来代码

    def add_security_headers(resp):
        default_src = ([host.strip() for host in config.config_trustedhosts.split(',') if host] +
                       ["'self'", "'unsafe-inline'", "'unsafe-eval'"])
        csp = "default-src " + ' '.join(default_src)
        if request.endpoint == "web.read_book" and config.config_use_google_drive:
            csp +=" blob: "
        csp += "; font-src 'self' data:"
        if request.endpoint == "web.read_book":
            csp += " blob: "
        csp += "; img-src 'self'"
        if request.path.startswith("/author/") and config.config_use_goodreads:
            csp += " images.gr-assets.com i.gr-assets.com s.gr-assets.com"
        csp += " data:"
        if request.endpoint == "edit-book.show_edit_book" or config.config_use_google_drive:
            csp += " *"
        if request.endpoint == "web.read_book":
            csp += " blob: ; style-src-elem 'self' blob: 'unsafe-inline'"
        csp += "; object-src 'none';"
        resp.headers['Content-Security-Policy'] = csp
        resp.headers['X-Content-Type-Options'] = 'nosniff'
        resp.headers['X-Frame-Options'] = 'SAMEORIGIN'
        resp.headers['X-XSS-Protection'] = '1; mode=block'
        resp.headers['Strict-Transport-Security'] = 'max-age=31536000'
        return resp

    修改为以下代码

    def add_security_headers(resp):
        default_src = ([host.strip() for host in config.config_trustedhosts.split(',') if host] +
                       ["'self'", "'unsafe-inline'", "'unsafe-eval'"])
        csp = "default-src " + ' '.join(default_src)
        if request.endpoint == "web.read_book" and config.config_use_google_drive:
            csp +=" blob: "
        csp += "; font-src 'self' data:"
        if request.endpoint == "web.read_book":
            csp += " blob: "
        csp += "; img-src 'self'"
        if request.endpoint == "web.read_book":
            csp += " https: http: blob:"  
        if request.path.startswith("/author/") and config.config_use_goodreads:
            csp += " images.gr-assets.com i.gr-assets.com s.gr-assets.com"
        csp += " data:"
        if request.endpoint == "edit-book.show_edit_book" or config.config_use_google_drive:
            csp += " *"
        if request.endpoint == "web.read_book":
            csp += " ; style-src-elem 'self' blob: 'unsafe-inline'"
        csp += "; object-src 'none';"
        resp.headers['Content-Security-Policy'] = csp
        resp.headers['X-Content-Type-Options'] = 'nosniff'
        resp.headers['X-Frame-Options'] = 'SAMEORIGIN'
        resp.headers['X-XSS-Protection'] = '1; mode=block'
        resp.headers['Strict-Transport-Security'] = 'max-age=31536000'
        return resp

    cps增加http:和https:,支持外部图片资源

  2. 修复JS报错:D:\calibre-web-master\cps\static\js\libs\reader.min.js

    将原来

    this.rendition=c.renderTo("viewer",{ignoreClass:"annotator-hl",width:"100%",height:"100%"})
  3. 修改为

    this.rendition=c.renderTo("viewer",{ignoreClass:"annotator-hl",width:"100%",height:"100%",allowScriptedContent:true})

    增加 allowScriptedContent:true 参数

扫描二维码推送至手机访问。

版权声明:本文由Ant.Master's Blog发布,如需转载请注明出处。

本文链接:https://iant.work/post/899.html

分享给朋友:

“Calibre-Web修复跨域问题” 的相关文章

内存不能被read或written错误,系统不停重启

运行某些程序的时候,有时会出现内存错误的提示,然后该程序就关闭。 “0x????????”指令引用的“0x????????”内存。该内存不能为“read”。 “0x????????”指令引用的“0x????????”内存,该内存不能为“written”。 一般出现这个现象...…

我的爱人生病了

   我的爱人5月29号生病了。当时,我真得非常紧张。因为您每次病都是那么严重的。每次都让我非常担心。这次,又真得让我忙了三天了。最后,我发觉是您的内存条问题。我万万想不到是您的内存条。内存条生病了...…

0X????????”指令引用的“0x00000000”内存,该内存不能为“read

使用Windows操作系统的人有时会遇到这样的错误信息: 「“0X????????”指令引用的“0x00000000”内存,该内存不能为“read”或“written”」,然后应用程序被关闭。 如果去请教一些「高手」,得到的回答往往是「Windows就是这样不稳定…

杀掉进程---介绍微软一个罕为人知的无敌命令

    问:怎么才能关掉一个用任务管理器关不了的进程?  我前段时间发现我的机子里多了一个进程,只要开机就在,我用任务管理器却怎么关也关不了。     答1:杀进程很容易,随便找个工具都行。比如IceSwor...…

IE注册表设置安全项

Windows安全设置之注册表项在IE4.0以上的版本中,IE的安全设置一般都存贮在这两个地方:1、HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings2、HKEY_LOCAL_MACHINE\SO…

显示图标小箭头

Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\PIPFile]"IsShortcut"=""[HKEY_CLASSES_ROOT\lnkfile]"IsShortcut"="" 以上代码保存为.reg文件!…

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。