Fix regex to not take email uids as federated ids

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-03-03 17:19:34 +01:00
parent 6ea1aef031
commit d612aeec2d
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -25,13 +25,14 @@
* @namespace * @namespace
*/ */
OCA.Sharing.Util = { OCA.Sharing.Util = {
/** /**
* Regular expression for splitting parts of remote share owners: * Regular expression for splitting parts of remote share owners:
* "user@example.com/path/to/owncloud" * "user@example.com/"
* "user@anotherexample.com@example.com/path/to/owncloud * "user@example.com/path/to/owncloud"
*/ * "user@anotherexample.com@example.com/path/to/owncloud
_REMOTE_OWNER_REGEXP: new RegExp('^([^@]*)@(([^@]*)@)?([^/]*)([/](.*)?)?$'), */
_REMOTE_OWNER_REGEXP: new RegExp('^(([^@]*)@(([^@^/^\\s]*)@)?)([^[\\s/]*)([/](.*))?$'),
/** /**
* Initialize the sharing plugin. * Initialize the sharing plugin.
@ -350,26 +351,24 @@
*/ */
_formatRemoteShare: function(shareWith, shareWithDisplayName, message) { _formatRemoteShare: function(shareWith, shareWithDisplayName, message) {
var parts = OCA.Sharing.Util._REMOTE_OWNER_REGEXP.exec(shareWith) var parts = OCA.Sharing.Util._REMOTE_OWNER_REGEXP.exec(shareWith)
if (!parts) { if (!parts || !parts[6]) {
// display avatar of the user // display avatar of the user
var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + ' ' + escapeHTML(shareWithDisplayName) + '"></span>' var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + ' ' + escapeHTML(shareWithDisplayName) + '"></span>'
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ' var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> '
return avatar + hidden return avatar + hidden
} }
var userName = parts[1] var userName = parts[2]
var userDomain = parts[3] var userDomain = parts[4]
var server = parts[4] var server = parts[5]
var tooltip = message + ' ' + userName
if (userDomain) { var tooltip = message + ' ' + userName
tooltip += '@' + userDomain if (userDomain) {
} tooltip += '@' + userDomain
if (server) { }
if (!userDomain) { if (server) {
userDomain = '…' tooltip += '@' + server
} }
tooltip += '@' + server
}
var html = '<span class="remoteAddress" title="' + escapeHTML(tooltip) + '">' var html = '<span class="remoteAddress" title="' + escapeHTML(tooltip) + '">'
html += '<span class="username">' + escapeHTML(userName) + '</span>' html += '<span class="username">' + escapeHTML(userName) + '</span>'