apache / apache/brpc

url encoding相关的问题

Open
#203 0 comments 0 reactions 0 assignees View on GitHub
enhancement official
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

这个问题其实还挺复杂的,主要是标准不统一,还和字符编码(utf8, gbk)搞在一起。
percent encoding本身是简单的,关键是哪些字符要encode。网上很多实现是认为0-9A-Za-z-._~予以保留,其他做percent encoding。但这其实是假设只encode query value。url是不能直接用的,至少浏览器都不是这个行为。结合google的文档和rfc3986,以及chrome的做法,大概是外加! * ' ( ) ; : @ & = + $ , / ? % # [ ]这些字符也保留不变。query中的空格转成+是个可选项,chrome是把空格转成%20而不是+。实现成这样的话,不管用户是对整个url,还是某个query value用,应该都是ok的。

另一个问题是http解析的地方要不要做decoding(否则path可能对不上)。目前看上去可能不做更靠谱,因为在url上出现中文本来也不是个方便的事情。兼容性太差了。

- [ ] 把PercentEncoding/Decoding移动到butil下,优化性能和接口
- [ ] 实现url encoding/decoding

Contributor guide

Open the contributing guide

Research direction

Locate the current PercentEncoding/Decoding implementation and the HTTP URL parsing entry points mentioned by the issue. Compare their behavior with RFC3986, Google’s guidance, and Chrome’s handling of reserved characters, UTF-8/GBK, and spaces. Done means the utilities are moved to butil with a defined interface and performance expectations, URL encoding/decoding is implemented, and HTTP decoding behavior is decided and covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.