Skip to content

Add non UTF-8 text support for url encode/url decode - #18314

Merged
Bahex merged 5 commits into
nushell:mainfrom
Bahex:url-encode-decode-non-utf8
Jun 12, 2026
Merged

Bahex merged 5 commits into
nushell:mainfrom
Bahex:url-encode-decode-non-utf8

Conversation

@Bahex

@Bahex Bahex commented May 30, 2026 •

Copy link
Copy Markdown
Member

Description

  • I wanted to see if I could write a helper command in nu for handling "Content-Disposition" headers as described in save: derive the default filename from metadata #18292
  • Researched how it should be parsed
  • Realize it's not as straightforward as one might expect: RFC 5987, section-3.2.2
    • filename="easy peasy.txt"
    • filename*=iso-8859-1'en'%A3%20rates.txt (not so easy 😔)
  • Try
    '%A3%20rates' | url decode  # | decode iso-8859-1
    And fail
     Error: nu::shell::error
    
      × Failed to decode string
       ╭─[repl_entry #1:1:1]
     1 │ '%A3%20rates' | url decode  # | decode iso-8859-1
       · ──────┬──────
       ·       ╰── invalid utf-8 sequence of 1 bytes from index 0
       ╰────
    
  • Rejoice 🎉
    '%A3%20rates' | url decode --binary | decode iso-8859-1
    # => £ rates

User-facing changes (Release notes)

  • url encode can now encode binary input too, adding support for encoding non UTF-8 texts
    '£ rates' | encode iso-8859-1 | url encode
    # => %A3%20rates
  • url decode can now decode inputs that do not evaluate to UTF-8 texts by returning a binary value (only with the --binary switch)
    '%A3%20rates' | url decode --binary | decode iso-8859-1
    # => £ rates

@Bahex Bahex added notes:ready Indicates Ready for Release notes notes:additions Noted in "Additions" section labels May 30, 2026
@Bahex
Bahex force-pushed the url-encode-decode-non-utf8 branch from 11e3872 to 5bc4a7d Compare June 12, 2026 22:34
@Bahex
Bahex merged commit 609383f into nushell:main Jun 12, 2026
17 checks passed
@github-actions github-actions Bot added this to the v0.114.0 milestone Jun 12, 2026
@Bahex
Bahex deleted the url-encode-decode-non-utf8 branch June 17, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants