Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why should the username matter? In my systems, I could have an insane URL like...

  https://myservice.com/my.super.duper.crazy-ass.user.name.pdf.exe
and still have it return a proper HTML document that covers that user's profile page. Hell, the username could be some insane zalgo-tier shit and still function properly.

I see some comments defending arbitrary "bandaid" architecture and I think that this is not defensible for something the scale of GitLab. This is basic HTTP stuff.



Of note, GitHub doesn't allow periods in usernames either. I'm not a Ruby expert but I wonder if file extensions give some specific Ruby gotchas that means both GitLab and GitHub operate this way.


It's not a Ruby gotcha, it's a Rails routing gotcha. You can specify alternative formats on any path, e.g. you can access /path to get HTML (or whatever the "default" format for that controller method is) or you can access /path.json or /path.xml and if the controller method specifies handlers for those formats, you get that format. So if you allow a username like "john.doe" and the route is something like /john.doe then Rails will interpret the "john" as the ID part of the path and "doe" as the format part of the path. You can override this in your routes to support periods but then you do lose the capability of accessing alternative formats which sometimes can be useful.


Thanks. Now I also get a better understanding of why .patch for MRs or .keys for user names as file extension work on both Rails platforms. I always found these file extension hacks very useful for quick access and automation.

Examples:

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70427....

https://gitlab.com/dnsmichi.keys


Ruby? No. Rails? Perhaps. (Both github and gitlab are built with ruby on rails).

For an old post on a somewhat related topic, see:

https://ryanbigg.com/2009/04/how-rails-works-2-mime-types-re...

I could imagine the mix of rails #respond_to and "file extensions" at the end of urls might make a mess (think /users/profile/smith.html vs /smith vs /smith.json vs /smith.txt - essentially what might have been /smith?format=json etc).

Ed: current documentation: https://apidock.com/rails/v6.1.3.1/ActionController/MimeResp...


I meant to say Rails.

Note to self: Never say Ruby when you mean Rails on HN


Some apps like to allow usernames to be used as sub domains and so periods are not allowed.


Hi, how would you address this in GitLab's code? Maybe you'd like to create a merge request with suggested fixes :)

https://news.ycombinator.com/item?id=28540665 has all URLs and issues available to get started in the code.


It’s not his job to fix a paid product.


I would begin by familiarizing myself with the Content-Type HTTP header:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Co...

As for actually performing this change myself, it would take me quite some time to grok the codebase.

Maybe I get bored tonight and see how hard this would be to resolve.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: