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

utf8-url encoded username url support (simple solve) #1949

Closed
shangjiaxuan opened this issue Dec 3, 2019 · 8 comments
Closed

utf8-url encoded username url support (simple solve) #1949

shangjiaxuan opened this issue Dec 3, 2019 · 8 comments
Labels
stale Issues that have had over 90 days of inactivity

Comments

@shangjiaxuan
Copy link

Feature Request

Is your feature request related to a problem? Please describe.
I am having problem if I manually allow usernames to contain spaces and non-ASCII characters and use a link to go to the user page, it would trigger a 404 error (url encoded strings are not converted).

Describe the solution you'd like
A detailed description of your proposed solution. Include:

  • How the feature would work/behave
  • Any potential drawbacks
  • Maybe a screenshot, design, or example code

Modify the following kines in function protected function data(ServerRequestInterface $request, Document $document) in src/Api//Controller/ShowUserController.php

if (! is_numeric($id)) {
    $id = $this->users->getIdForUsername($id);
}

to

if (! is_numeric($id)) {
    $id = $this->users->getIdForUsername(urldecode($id));
}

Tested on my forum at this site. As shown here in Firefox:
test1
test2

Justify why this feature belongs in Flarum's core, rather than in a third-party extension
This changes the behavior of core api. Also the overhead involved with a decode on strings that are not percent-encoded may not be too high (not metered). This would allow removing the restriction on username characters (spaces allowed as encoded %20 in url request) at least on the user display side.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Probably implement this somewhere in a extension.

@shangjiaxuan
Copy link
Author

grep -r 'numeric' on src directory gives only this and a line in ./Util/Str.php, and grep -r 'alpha' only gives ./Util/Str.php. Most likely there won't be security issues involved.

@shangjiaxuan
Copy link
Author

Note: Using space in username breaks post cross referencing. Allowing space is more tricky here.

@shangjiaxuan
Copy link
Author

It seems that this post mentions a rather good solution to the username with @mention system by recognizing @"mention user". Making this and changing a bit how UserValidater.php works (allow more characters) should allow an complete extension that allow spaces, non-ascii and other characters in the username.

@luceos
Copy link
Member

luceos commented Dec 6, 2019

related #1356

@franzliedke
Copy link
Contributor

More cross-reference: #557 and flarum/issue-archive#254

@tankerkiller125
Copy link
Contributor

tankerkiller125 commented Feb 24, 2020

I'm not a huge fan of allowing space, but I did discover that apha_dash as the validator instead of regex would allow unicode characters to be used as a username. We would need to figure out proper slugging though.

@stale
Copy link

stale bot commented May 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum.
In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!

@stale stale bot added the stale Issues that have had over 90 days of inactivity label May 24, 2020
@stale
Copy link

stale bot commented Jun 23, 2020

We are closing this issue as it seems to have grown stale. If you still encounter this problem with the latest version, feel free to re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that have had over 90 days of inactivity
Projects
None yet
Development

No branches or pull requests

4 participants