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

remove use of like #1787

Merged
merged 1 commit into from
Jun 3, 2019
Merged

remove use of like #1787

merged 1 commit into from
Jun 3, 2019

Conversation

luceos
Copy link
Member

@luceos luceos commented May 29, 2019

This relates to flarum/tags#61 (comment)

The point is that by using like in situation where an _ is used, it allows a one character replacement in MySQL. As such when you have a key named tes_ and tes1 by using $key = 'tes_' it might return tes1 instead, which is unwanted.

There are two places this happens. The first one is in the UserRepository, which is being used by the xhr to retrieve a user profile. @meezaan reported he already experienced this issue on his installation where usernames had spaces replaced with underscores. The second one is for the settings repository, this delete method is only used inside the Setting Migration, so it can use an exact match too.

@luceos luceos added this to the 0.1.0-beta.9 milestone May 31, 2019
@luceos
Copy link
Member Author

luceos commented Jun 3, 2019

As @tobyzerner points the initial select is already case insensitive, can we close this without a change?

@franzliedke
Copy link
Contributor

Well, this PR doesn't change case-sensitivity (which is great, and I didn't know that), but it does prevent the special characters _ and % from affecting the query. Apparently, we do not need LIKE here.

@franzliedke franzliedke merged commit ee3640e into master Jun 3, 2019
@franzliedke franzliedke deleted the dk/drop-like branch June 3, 2019 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants