Coder Social home page Coder Social logo

Comments (14)

RossWang avatar RossWang commented on June 18, 2024

可以提供連結嗎,因為我這邊試不出來
百度傳來的格式:
default
解碼方法:
default

from aria2-integration.

Aetf avatar Aetf commented on June 18, 2024

https://pan.baidu.com/s/1geOdzu7

以及能告诉我是怎么看到百度传过来的数据的吗?我想试试在我这边直接用decodeURI试试看,也许跟系统本身默认的编码有关(我的应该是 UTF-8)

from aria2-integration.

Aetf avatar Aetf commented on June 18, 2024

image

hmmm 稍微试了一下,火狐返回的结果很奇怪,或者是百度返回的数据很奇怪,根本不是 URI 编码的。必须用 utf-8 解码两次才能拿到正确的结果。

image

browser.webRequest.onHeadersReceived.addListener(e => {
  let encoder = new TextEncoder();
  let de1 = new TextDecoder('utf-8');
  for (const h of e.responseHeaders) {
    if (h.name === "Content-Disposition") {
      let bv = []; if (h.value) {
        bv = encoder.encode(h.value);
      } else {
        bv = h.binaryValue;
      }
      console.log('Binary values: ', bv.toString());
      d1 = de1.decode(bv);
      console.log('after utf-8 decode: ', d1);
      bv2 = [];
      for (let i = 0; i != d1.length; ++i) {
        bv2.push(d1.charCodeAt(i));
      }
      bv2 = new Uint8Array(bv2)
      console.log('code points: ', bv2)

      d2 = de1.decode(bv2)
      console.log('utf8 decode again: ', d2)
    }
  }
}, {urls : [ "<all_urls>" ]}, [ "blocking", "responseHeaders" ])

from aria2-integration.

RossWang avatar RossWang commented on June 18, 2024

看起來是Linux版本的差異
在Windows上,browser.webRequest 傳過來時就已經轉換好了

雖然是Firefox的問題,我還是修正一下好了
但是這樣要怎麼分辨是iso-latin還是utf-8啊?

from aria2-integration.

heydudeyan avatar heydudeyan commented on June 18, 2024

在windows上用也存在文件名乱码,请问具体怎么解决呢?另外不能选择文件保存位置怎么解决?

from aria2-integration.

no1xsyzy avatar no1xsyzy commented on June 18, 2024

@yans006 每个问题应该单独发issue。这边的保存位置并不是通过界面完成的,需要手动输入。需要对话框可以发Feature Request。

from aria2-integration.

yingziwu avatar yingziwu commented on June 18, 2024

@RossWang
同样遇见这样的问题。

具体情况如下:
Name Firefox
Version 59.0.2
OS Linux 4.15.15-1-ARCH

网址:https://pan.baidu.com/s/1VkyPSo-_zUWPoIcbO12bBg
提取码:5vlm

出错截图:
screenshot_20180408_214002

截图中"File name"栏中的内容: [å��æ�¬ã�¹ã�¤].é��è�²ç��æ��å­�使.03.epub

所有请求的har文件:
Archive 18-04-08 21-42-01.har.zip

from aria2-integration.

yingziwu avatar yingziwu commented on June 18, 2024

@RossWang @Aetf

特别将最关健的一个请求单独贴在下面。

screenshot-2018-4-8 http archive viewer 2 0 17
screenshot-2018-4-8 http archive viewer 2 0 17 1

从上面的两面图中可以看出,请求参数finfn中均包含正确的文件名。
而服务器响应Content-Disposition中则给出了一个未知编码的文件名。

经实验,该字段可通过如下方式还原。
screenshot_20180408_222608

$ echo '[å^Í^Áæ^ܬã^¹ã^¤].é^Ç^Ñè^ɲç^Ú^Äæ^Ö^Çå<00ad>^×使.03.epub' | iconv -f UTF-8 -t LATIN1
[十本スイ].金色的文字使.03.epub

由于复制的原因,上面代码框中的代码直接复制到终端并不能得到图片中所示的结果。
为了得到相同结果,你可以打开har文件,复制11314行中的文件名部分,替换上面bash命令中文件名部分进行执行。

当然,你也可以执行如下命令:

$ echo 'W8Olwo3CgcOmwpzCrMOjwoLCucOjwoLCpF0uw6nCh8KRw6jCicKyw6fCmsKEw6bClsKHw6XCrcKX
w6TCvcK/LjAzLmVwdWIK' | base64 -d | iconv -f UTF-8 -t LATIN1
[十本スイ].金色的文字使.03.epub

screenshot_20180408_223725

希望上述内容能够对作者有所帮助。
也希望作者能尽快修复这个bug。

from aria2-integration.

yingziwu avatar yingziwu commented on June 18, 2024

雖然是Firefox的問題,我還是修正一下好了
但是這樣要怎麼分辨是iso-latin還是utf-8啊?

也许作者可以换一个思路
比如说,对于百度盘的链接(baidupcs.com),直接从请求的fnfin字段拿文件名,不理会Content-Disposition中的内容。

from aria2-integration.

RossWang avatar RossWang commented on June 18, 2024

Reference:
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa

大家幫我試一下,我目前沒有環境可以測試

from aria2-integration.

Mapaler avatar Mapaler commented on June 18, 2024

在一个DZX论坛下载附件,不使用扩展可以正常下载
screenshot 2018-09-06 18 03 29
使用扩展会下载失败
screenshot 2018-09-06 18 03 51
screenshot 2018-09-06 18 04 05
论坛用的是GBK版
screenshot 2018-09-06 18 04 21

from aria2-integration.

RossWang avatar RossWang commented on June 18, 2024

在一个DZX论坛下载附件,不使用扩展可以正常下载
screenshot 2018-09-06 18 03 29
使用扩展会下载失败
screenshot 2018-09-06 18 03 51
screenshot 2018-09-06 18 04 05
论坛用的是GBK版
screenshot 2018-09-06 18 04 21

兩個問題,第一個是編碼,第二個是無法下載
編碼的部分我在相似的網站上可以復現,但是還無解
無法下載的部分是因為Webextension API 不支持傳遞Referer,所以論壇驗證不通過
此類下載僅能透過Aria2下載

from aria2-integration.

zombie110year avatar zombie110year commented on June 18, 2024

更新了 0.4.0 版本后出现了编码错误...
下载文件的 URL 编码是

%5B%E4%B8%96%E6%8D%A8%E4%BA%BA%E3%81%AA%E6%BC%AB%E7%94%BB%E6%8F%8F%E3%81%8D%20%28%E3%81%A8%E3%82%82%E3%81%8D%E3%81%A8%E3%82%82%E3%81%AE%E3%82%8A%29%5D%20%E5%AF%BE%E5%9C%B0%E7%90%83%E4%BA%BA%E6%80%A7%E6%AC%B2%E5%88%B6%E5%BE%A1%E7%94%A8%E4%BA%BA%E9%80%A0%E4%BA%BA%E9%96%93%E3%82%A2%E3%83%AA%E3%82%B9%20%28%E4%B8%8D%E6%80%9D%E8%AD%B0%E3%81%AE%E5%9B%BD%E3%81%AE%E3%82%A2%E3%83%AA%E3%82%B9%29%20%5B%E4%B8%AD%E5%9B%BD%E7%BF%BB%E8%A8%B3%5D%20%5BDL%E7%89%88%5D.zip

被解析为

[�hºj+;ÏM (h‚Mh‚nŠ)] þ0�º'26¡(º º“¢ê¹ (�pnýn¢ê¹) [-ýû3] [DLH].zip

from aria2-integration.

zombie110year avatar zombie110year commented on June 18, 2024

我不太懂这个, 很可惜帮不上忙...

from aria2-integration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.