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

图片 base64 编码问题:中文路径,网络图片 #436

Open
1 of 3 tasks
linsui opened this issue May 7, 2019 · 16 comments
Open
1 of 3 tasks

图片 base64 编码问题:中文路径,网络图片 #436

linsui opened this issue May 7, 2019 · 16 comments
Labels
Area: Exporting To HTML. Probably also other formats someday. Issue: Bug

Comments

@linsui
Copy link
Contributor

linsui commented May 7, 2019

#415#429 相关

  1. 当图片路径中有中文时无法转换为 base64
  2. 网络图片无法转换为 base64
  3. 本地图片无法转换为 base64 时,生成的路径中无 file:/// ,导致无法打开
@yzhang-gh
Copy link
Owner

第一个问题需要我检查一下

至于第二个问题,
相对路径时应该是不能有 file:/// 的,
绝对路径时浏览器好像默认会阻止读取本地资源(最新的 FireFox 和 Chrome 都不行)
感觉 file:/// 没有用处

@linsui
Copy link
Contributor Author

linsui commented May 7, 2019

第二个问题,当设置为不使用 base64 编码时,是 file:///d:\..\..\a.jpg 的,但转换失败保留路径时,是 d:\..\..\a.jpg 。现在生成的就是绝对路径。 😕

@yzhang-gh
Copy link
Owner

你加上 file:/// 之后可以打开吗,我印象里加了也不行

@linsui
Copy link
Contributor Author

linsui commented May 8, 2019

不转换为 base64 编码时的链接有 file:/// ,图片可以显示。转换失败的没有,Firefox 不显示但 Chrome 能显示。

@yzhang-gh
Copy link
Owner

yzhang-gh commented May 8, 2019

头疼的是不同的时候测试结果还不一样


我的电脑上 (Windows)

Chrome (74.0.3729.131) Firefox (66.0.4)
Has file:///
No file:///

(和你一样)


然而,#415 (Linux) 说

Now print to html. The problem seems to be with the file:/// used. (<img src="file:///14.png" alt="">). If I remove file:/// it works.

Chrome (?) Firefox (?)
Has file:/// -
No file:/// -

(注意测试时使用 "Ctrl + F5" 忽略缓存刷新)


所以现在有点无法确定

@linsui
Copy link
Contributor Author

linsui commented May 8, 2019

我在 ubuntu 上测试了一下 Firefox 都可以打开。 #415 中的问题应该是相对路径引起的,在 file:/// 后必须是绝对路径

@yzhang-gh
Copy link
Owner

谢谢,周末有时间来修复

yzhang-gh added a commit that referenced this issue May 12, 2019
@yzhang-gh
Copy link
Owner

问题二解决了
问题一我查看了一下,是 markdown-it 对路径做了编码,中文 变成了 %E4%B8%AD%E6%96%87(这个问题我暂时先不管了,怕出现什么副作用)

@linsui
Copy link
Contributor Author

linsui commented May 13, 2019

谢谢,图片显示正常 👍 但公式无法预览了

有个地方行为不太符合预期,当不勾选转换绝对路径,勾选 base64 ,转换 base64 失败时,得到的是绝对路径而不是相对路径。这和不勾选 base64 的行为不一致。

只有本地图片转换为 base64 编码了,网络图片无法转换吗?

@linsui linsui changed the title 图片路径问题 图片路径问题:中文路径 base64 编码失败 May 13, 2019
@yzhang-gh
Copy link
Owner

但公式无法预览了

我这好像是正常的,有没有样本让我测试一下

当不勾选转换绝对路径,勾选 base64 ,转换 base64 失败时,得到的是绝对路径而不是相对路径

有道理,会改一下(之前的想法是,既然勾选了 base64,表示要把图片搞得决绝一点,就换成绝对路径了)

只有本地图片转换为 base64 编码了,网络图片无法转换吗?

主要是涉及到网络请求,怕麻烦就没做😂

yzhang-gh added a commit that referenced this issue May 13, 2019
@linsui

This comment has been minimized.

@yzhang-gh

This comment has been minimized.

@linsui

This comment has been minimized.

@yzhang-gh

This comment has been minimized.

@linsui

This comment has been minimized.

yzhang-gh added a commit that referenced this issue May 14, 2019
@yzhang-gh

This comment has been minimized.

@linsui linsui changed the title 图片路径问题:中文路径 base64 编码失败 图片路径和 base64 编码问题 Jun 15, 2019
@yzhang-gh yzhang-gh added Area: Exporting To HTML. Probably also other formats someday. Issue: Bug labels Sep 1, 2020
@yzhang-gh yzhang-gh changed the title 图片路径和 base64 编码问题 图片 base64 编码问题:中文路径,网络图片 Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Exporting To HTML. Probably also other formats someday. Issue: Bug
Projects
None yet
Development

No branches or pull requests

2 participants