Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken Devvit login link in Windows Terminal #119

Open
kevburnsjr opened this issue Nov 27, 2024 · 1 comment
Open

Broken Devvit login link in Windows Terminal #119

kevburnsjr opened this issue Nov 27, 2024 · 1 comment

Comments

@kevburnsjr
Copy link

kevburnsjr commented Nov 27, 2024

  1. Run devvit login
  2. Control click the link in the terminal

image

@kevburnsjr
Copy link
Author

kevburnsjr commented Nov 27, 2024

I ran devvit login from WSL using Windows Terminal and control clicked the generated URL to open this page which only included part of the URL. The last parameter, devvit_cli was ommitted.

The problem is the unescaped asterisk in URL param &scope=* in the URL.
Some popular terminal applications like this consider the asterisk and everything after it as not part of the URL.

See RFC 3986 - URIs - Section 2.2

2.2.  Reserved Characters

   URIs include components and subcomponents that are delimited by
   characters in the "reserved" set.  These characters are called
   "reserved" because they may (or may not) be defined as delimiters by
   the generic syntax, by each scheme-specific syntax, or by the
   implementation-specific syntax of a URI's dereferencing algorithm.
   If data for a URI component would conflict with a reserved
   character's purpose as a delimiter, then the conflicting data must be
   percent-encoded before the URI is formed.

      reserved    = gen-delims / sub-delims

      gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

      sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
                  / "*" / "+" / "," / ";" / "="

Since every URL is a URI and the URL scheme syntax does not specify a purpose for the * reserved character, it should always be encoded wherever it appears in URLs.

However, RFC 1738 - URLs - Section 2.2 states:

   Usually a URL has the same interpretation when an octet is
   represented by a character and when it encoded. However, this is not
   true for reserved characters: encoding a character reserved for a
   particular scheme may change the semantics of a URL.

   Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
   reserved characters used for their reserved purposes may be used
   unencoded within a URL.

   On the other hand, characters that are not required to be encoded
   (including alphanumerics) may be encoded within the scheme-specific
   part of a URL, as long as they are not being used for a reserved
   purpose.

In the face of this apparent contradiction, some terminal applications like Windows Terminal choose the conservative approach, opting to only hyperlink valid URIs. Probably for security purposes.

Replacing * with %2A in the devvit login URL functions correctly. No backend modifications required.


tl;dr - Recommend URL Encoding the asterisk as %2A in the scope parameter to improve terminal compatibility.

Update: This is already fixed in some places (here) but not others (here)

@kevburnsjr kevburnsjr changed the title Devvit login doesn't work Broken Devvit login link in Windows Terminal Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant