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

When the " character exists in the hyperlink element address, the paste cannot be parsed normally #11385

Closed
TCOTC opened this issue May 14, 2024 · 16 comments
Assignees
Labels
Milestone

Comments

@TCOTC
Copy link
Contributor

TCOTC commented May 14, 2024

粘贴链接时,把 URL 中的保留和不安全字符自动转换为 URL 编码

In what scenarios do you need this feature?

  1. [在必应搜索 "你好"](www.bing.com/search?q="你好") 粘贴到思源内,会丢失链接部分 " 及后面的字符,变成 [在必应搜索 "你好"](www.bing.com/search?q=)
  2. [在必应搜索 "你好"](www.bing.com/search?q=%22你好%22) 粘贴到思源内则是正常的,点击超链接也能正常打开网页
  3. 复制 www.bing.com/search?q=%22你好%22 ,在思源内选中文本 Ctrl+K 或者直接粘贴,会丢失链接部分 及后面的字符,变成 http://www.bing.com/search?q=%22

Describe the optimal solution

建议在粘贴链接时,把 URL 中的保留和不安全字符(" 和非英文之类的)自动转换为 URL 编码

[在必应搜索 "你好"](www.bing.com/search?q="你好") 粘贴后变为 [在必应搜索 "你好"](www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22) (符号和中文都转换)

Describe the candidate solution

复制 www.bing.com/search?q=%22你好%22 ,在思源内选中文本 Ctrl+K 或者直接粘贴,会丢失链接部分 及后面的字符,变成 http://www.bing.com/search?q=%22

另外,这个 http:// 有必要自动加上吗?明明去掉之后点击也可以打开网页

Other information

No response

@88250 88250 self-assigned this May 14, 2024
@88250 88250 changed the title 粘贴链接时,把 URL 中的保留和不安全字符自动转换为 URL 编码 When the " character exists in the hyperlink element address, the paste cannot be parsed normally May 15, 2024
@88250 88250 added the Bug label May 15, 2024
@88250 88250 added this to the 3.0.15 milestone May 15, 2024
@88250
Copy link
Member

88250 commented May 15, 2024

这个 http:// 有必要自动加上吗?

最好手动加,否则可能会被某些解析器识别为相对路径,比如 GitHub:

image

88250 added a commit to 88250/lute that referenced this issue May 15, 2024
88250 added a commit that referenced this issue May 15, 2024
@88250 88250 closed this as completed May 15, 2024
@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

这个 http:// 有必要自动加上吗?

最好手动加,否则可能会被某些解析器识别为相对路径,比如 GitHub:

这样的话加 https:// 会不会更好?多数网站都是 https ,有的网站用 http 会打不开

@88250
Copy link
Member

88250 commented May 15, 2024

嗯,主流已经是 https

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

刚刚打包试了一下:

  1. 复制 www.bing.com/search?q=%22你好%22 ,在思源内选中文本 Ctrl+K 或者直接粘贴,会变成 http://www.bing.com/search?q=%22 → 【问题】丢失了链接部分 及后面的字符
  2. 复制 www.bing.com/search?q="你好" ,在思源内选中文本 Ctrl+K 或者直接粘贴,会变成 http://www.bing.com/search?q= → 【问题】丢失了链接部分 " 及后面的字符
  3. 以上自动添加的 http:// 需要改为 https://
  4. 复制 [在必应搜索 "你好"](www.bing.com/search?q="你好") ,在思源内选中文本 Ctrl+K 或者直接粘贴,会添加链接 www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22 → 【问题】前面少了 https://
  5. 复制 [在必应搜索 "你好"](www.bing.com/search?q=%22你好%22) ,在思源内选中文本 Ctrl+K 或者直接粘贴,会添加链接 www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22 → 【问题】前面少了 https://

@88250 需要统一一下

建议把以上 4 种方式添加的链接都统一为 https://www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

另外除了 " ,其他符号会不会有同样的问题?我搜到 URL 保留字符和不安全字符 是有一堆的

image

@88250
Copy link
Member

88250 commented May 15, 2024

  • 3、4、5 不自动加 https,否则相对路径可能会有问题
  • 不是 URL 编码问题,是 DOM 属性值的问题

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

image

这个相对路径的问题要怎么复现?

@88250
Copy link
Member

88250 commented May 15, 2024

image

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

这个懂了。那自动添加的 http:// 不改为 https:// 的理由是什么?

  1. 以上自动添加的 http:// 需要改为 https://

@88250
Copy link
Member

88250 commented May 15, 2024

GFM 规范定义的 https://github.github.com/gfm/#autolinks-extension-

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

这两个呢:

  1. 复制 www.bing.com/search?q=%22你好%22 ,在思源内选中文本 Ctrl+K 或者直接粘贴,会变成 http://www.bing.com/search?q=%22 → 【问题】丢失了链接部分 及后面的字符
  2. 复制 www.bing.com/search?q="你好" ,在思源内选中文本 Ctrl+K 或者直接粘贴,会变成 http://www.bing.com/search?q= → 【问题】丢失了链接部分 " 及后面的字符

@88250
Copy link
Member

88250 commented May 15, 2024 via email

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

www.bing.com/search?q=%22你好%22www.bing.com/search?q="你好"

添加链接后应该变成 http://www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22

@88250
Copy link
Member

88250 commented May 15, 2024 via email

@TCOTC
Copy link
Contributor Author

TCOTC commented May 15, 2024

这两个已经是强制编码了的:

  1. 复制 [在必应搜索 "你好"](www.bing.com/search?q="你好") ,在思源内选中文本 Ctrl+K 或者直接粘贴,会添加链接 www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22
  2. 复制 [在必应搜索 "你好"](www.bing.com/search?q=%22你好%22) ,在思源内选中文本 Ctrl+K 或者直接粘贴,会添加链接 www.bing.com/search?q=%22%E4%BD%A0%E5%A5%BD%22

@88250
Copy link
Member

88250 commented May 15, 2024 via email

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

No branches or pull requests

2 participants