Skip to content
  • Ashe Connor's avatar
    e52ab312
    URI.unescape handles mixed Unicode/escaped input · e52ab312
    Ashe Connor authored
    
    
    Previously, URI.enscape could handle Unicode input (without any actual
    escaped characters), or input with escaped characters (but no actual
    Unicode characters) - not both.
    
        URI.unescape("\xe3\x83\x90")  # => "バ"
        URI.unescape("%E3%83%90")  # => "バ"
        URI.unescape("\xe3\x83\x90%E3%83%90")  # =>
                                             # Encoding::CompatibilityError
    
    We need to let `gsub` handle this for us, and then force back to the
    original encoding of the input.  The result String will be mangled if
    the percent-encoded characters don't conform to the encoding of the
    String itself, but that goes without saying.
    
    Signed-off-by: default avatarAshe Connor <ashe@kivikakk.ee>
    e52ab312
    URI.unescape handles mixed Unicode/escaped input
    Ashe Connor authored
    
    
    Previously, URI.enscape could handle Unicode input (without any actual
    escaped characters), or input with escaped characters (but no actual
    Unicode characters) - not both.
    
        URI.unescape("\xe3\x83\x90")  # => "バ"
        URI.unescape("%E3%83%90")  # => "バ"
        URI.unescape("\xe3\x83\x90%E3%83%90")  # =>
                                             # Encoding::CompatibilityError
    
    We need to let `gsub` handle this for us, and then force back to the
    original encoding of the input.  The result String will be mangled if
    the percent-encoded characters don't conform to the encoding of the
    String itself, but that goes without saying.
    
    Signed-off-by: default avatarAshe Connor <ashe@kivikakk.ee>
Loading