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

Comment mentions with spaces #11836

Merged
merged 2 commits into from
Nov 7, 2018

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Oct 15, 2018

  1. Create a user with a space in the user id: foo bar
  2. Share a file with the user
  3. Mention the user using autocompletion
  4. Look at the message

Before: Hi {{@Unknown user}} bar test
After: Hi {{@User with space in ID}} test

Fix #2443

@nickvergessen
Copy link
Member Author

nickvergessen commented Oct 15, 2018

The problem at the moment is, that the " is a word seperator, and therefor the regex does not match anymore, as the \b is not there:

// replace every mention either at the start of the input or after a whitespace
// followed by a non-word character.
message = message.replace(new RegExp("(^|\\s)(" + mention + ")\\b", 'g'),
function(match, p1) {
// to get number of whitespaces (0 vs 1) right
return p1+displayName;
}

In Talk we do the replacement in php with a simple str_replace and therefor do not have this problem.

So my idea would be to screw the word end check for quoted user ids.

@nickvergessen nickvergessen force-pushed the bugfix/2443/comment-mentions-with-spaces branch from 52723f0 to cd65fa1 Compare October 15, 2018 09:25
@nickvergessen nickvergessen added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 22, 2018
Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

Would you mind adding another test case to \Test\Comments\CommentTest::mentionsProvider() that supports the uid-with-space-scenario?

Otherwise, the code looks good and i like the simplicity

var $inserted = $this.parent();
$inserted.html('@' + $this.find('.avatar').data('username'));
var $this = $(this),
$inserted = $this.parent(),
Copy link
Member

Choose a reason for hiding this comment

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

Imho this style is rather confusing than improving readability. Might be just me tho.

Copy link
Member

Choose a reason for hiding this comment

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

@nickvergessen
Copy link
Member Author

Otherwise, the code looks good and i like the simplicity

I wanted to here this, before diving into tests, because if we don't agree on @"…" I dont waste time on the tests. So will do now.

@MorrisJobke
Copy link
Member

Even after rebase of this branch the user is not properly shown:

bildschirmfoto 2018-11-02 um 12 38 03

I used foo bar

@MorrisJobke MorrisJobke mentioned this pull request Nov 6, 2018
29 tasks
@nickvergessen
Copy link
Member Author

@MorrisJobke this is not retro-active, because the saved comment is different (old: @foo bar new: @"foo bar"). Did you create a new comment and use the autocompletion for it?

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the bugfix/2443/comment-mentions-with-spaces branch from cd65fa1 to 375589b Compare November 7, 2018 11:34
@nickvergessen
Copy link
Member Author

Added a unit test and rebased.

still working for me, so ready for review.

@MorrisJobke
Copy link
Member

@MorrisJobke this is not retro-active, because the saved comment is different (old: @foo bar new: @"foo bar"). Did you create a new comment and use the autocompletion for it?

Ah - I created the comment first and then changed the branch. Let me test again.

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Tested and works 👍

@MorrisJobke
Copy link
Member

Unrelated trash bin failure -> merge

@MorrisJobke MorrisJobke merged commit ab35433 into master Nov 7, 2018
@MorrisJobke MorrisJobke deleted the bugfix/2443/comment-mentions-with-spaces branch November 7, 2018 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants