Skip to content

strip whitespace from the beginning and end of the display name - #11595

Merged
blizzz merged 1 commit into
masterfrom
make_get_display_name_more_robust
Oct 16, 2014
Merged

blizzz merged 1 commit into
masterfrom
make_get_display_name_more_robust

Conversation

@schiessle

Copy link
Copy Markdown
Contributor

strip whitespace from the beginning and end of the display name to avoid empty display names

If a display name stored in the database contains whitespaces only we return the uid. Before we set a new display name we check if it contains real characters, not only whitespaces.

cc @blizzz @PVince81

fix #10817

@PVince81

Copy link
Copy Markdown
Contributor

@schiesbn did you test whether the search would work ?
The initial problem is that older OC versions somehow put a space inside those fields.

@schiessle

Copy link
Copy Markdown
Contributor Author

I don't know where the spaces come from. But this changes make the code more robust and ignore the white spaces... Of course I tested it and it works.

@PVince81

Copy link
Copy Markdown
Contributor

So does it mean the search isn't using SQL queries at all ?

@schiessle

Copy link
Copy Markdown
Contributor Author

I just strip the white spaces from the the beginning and the end of the display name. If the result is empty I return the UID, if not I return the display name.

@PVince81

Copy link
Copy Markdown
Contributor

I know. But your change would not fix SQL queries that directly interact with the database field, if that field contains a single space.

If you say the search does work with your fix, then it's fine.

Comment thread lib/private/user/user.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make it more robust, you check whether the returned value is a string. True (by hypothetical broken backend) would pass as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will add it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

@schiessle

Copy link
Copy Markdown
Contributor Author

For the search this doesn't make a difference. If you search for a user both a empty display name and a display name looking like " " won't match any real user name. The problem is that once we found a user by the uid, we should only return the display name as result if it contain "real" characters and not only white spaces.

@schiessle
schiessle force-pushed the make_get_display_name_more_robust branch from fb30cf0 to 239bff5 Compare October 15, 2014 12:55
@ghost

ghost commented Oct 15, 2014

Copy link
Copy Markdown

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/254/

Build result: FAILURE

GitHub pull request #11595 of commit 239bff5 automatically merged.Building remotely on vm-slave-02 (SLAVE) in workspace /var/jenkins/workspace/pull-request-analyser-ng-simple@13 > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.git > git --version # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git rev-parse origin/pr/11595/merge^{commit} # timeout=10Checking out Revision ba8f4131b5373435c75cff9decd487ef9763adf5 (detached) > git config core.sparsecheckout # timeout=10 > git checkout -f ba8f4131b5373435c75cff9decd487ef9763adf5 > git rev-list 4a99bf9a49077afbc888c6fcb5919cd9aee17b92 # timeout=10 > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » vm-slave-02Configuration pull-request-analyser-ng-simple » vm-slave-02 is still in the queue: Waiting for next available executor on vm-slave-02pull-request-analyser-ng-simple » vm-slave-02 completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 3 second
💣 Test FAILed. 💣

@PVince81

Copy link
Copy Markdown
Contributor

I tried setting the display names to " " directly in the database and the search worked with this fix.
On master it didn't.

Code looks good, works 👍

@PVince81

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 5 new issues, 4 updated code elements

@ghost

ghost commented Oct 15, 2014

Copy link
Copy Markdown

🚀 Test PASSed. 🚀
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/288/
🚀 Test PASSed. 🚀

@schiessle

Copy link
Copy Markdown
Contributor Author

second reviewer? @blizzz ? Thanks!

@blizzz

blizzz commented Oct 16, 2014

Copy link
Copy Markdown
Contributor

Yepp, code looks good 👍

blizzz added a commit that referenced this pull request Oct 16, 2014
…bust

strip whitespace from the beginning and end of the display name
@blizzz
blizzz merged commit 756f64d into master Oct 16, 2014
@blizzz
blizzz deleted the make_get_display_name_more_robust branch October 16, 2014 09:33
@blizzz

blizzz commented Oct 16, 2014

Copy link
Copy Markdown
Contributor

@karlitschek backport?

@karlitschek

Copy link
Copy Markdown
Contributor

Yes please

@schiessle

Copy link
Copy Markdown
Contributor Author

stable7: 6e3a7ea

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot share files with old users

6 participants