API To Determine if String Needs Encoding
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
Background
Sometimes you wish to take a string and verify that it has been correctly escaped. Particularly if % is in the escaped character list, you can't just percent-encode the string to be safe, as this will change the string.
This is exactly the case on https://github.com/apache/arrow-rs/pull/2356 where I wanted an API to check if a given byte is "legal".
Proposed Solution
AsciiSet::should_percent_encode would be perfect, however, it is private. I therefore hacked around this by doing
byte.is_ascii() || percent_encode(&[c], <AsciiSet>).next().unwrap().len() != 1
But it would be nicer if the method on AsciiSet were exposed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the private AsciiSet::should_percent_encode method and the percent_encode API described in the issue. Expose the method so callers can determine whether a byte needs percent encoding, then verify that the public API supports the stated legality check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100