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

Calibre-Web修复跨域问题

canca4周前 (01-20)电脑知识76
  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修复跨域问题” 的相关文章

我的爱人生病了

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

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

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

电脑启动报鸣声说明

当打开电脑时,听到的不是平时清脆的启动声,而是一次又一次重复的奇怪的报警声时,你能不能马上判断出故障的所在呢?虽然现在多家厂商都设计出一些智能化的功能,能将报警声转换成语音或是指示灯等,但是有这种功能...…

IE高级选项:允许活动内容在我的计算机上的文件中运行 对应注册表选项

IE高级选项:允许活动内容在我的计算机上的文件中运行 选中 对应的注册表选项 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN]"iexp…

显示图标小箭头

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

IVT BlueSoleil 10.0.417.0(X86&X64位)多语言注册版附破解补丁

IVT BlueSoleil 10.0.417.0(X86&X64位)多语言注册版附破解补丁

BlueSoleil是IVT公司推出的一款多语言版蓝牙驱动产品,它秉承了BlueSoleil系列一贯的简洁易用的功能特点,以及美观友好的操作界面,轻松帮您实现台式机或笔记本等各种计算机平台间的无线连接;无线访问种类繁多的具有蓝牙功能…

发表评论

访客

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