• Stan Hu's avatar
    Fix obsoleted URI.{encode,decode} calls for Ruby 2.7 · c0425241
    Stan Hu authored
    Attempting to use these calls results in these obsolete warnings:
    
    ```
    warning: URI.escape is obsolete
    ```
    
    As mentioned by the Knapsack Pro blog:
    
    
    > The trouble with a concept of “escaping the URI” is that URI consists of
    > many components (like path or query), and we don’t want to escape them
    > in the same way. For example, it’s fine for a # character to appear at
    > the end of the URI (when it’s used as what’s usually called an anchor,
    > or in URI parlance - a fragment component) - but when the same # is part
    > of user’s input (like in a search query), we want to encode it to ensure
    > correct interpretation. Similarly, if the query string value contains
    > other reserved characters, like = or &, we do want to escape them so
    > that they are not incorrectly interpreted as delimiters, as if they were
    > used as reserved characters.
    >
    > URI.escape relies on a simple gsub operation for the whole string and
    > doesn’t differentiate between distinct components, which doesn’t take
    > into account intricacies like those mentioned above.
    
    
    CGI.escape and CGI.encode_www_form_component are often mentioned as
    replacements, but both substitute spaces for `+` instead of `%20`. This
    doesn't work for Grafana. Using `%20` for spaces everywhere is valid,
    which is what `Addressable::URI` does.
    c0425241
auth_spec.rb 1.65 KB