-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
obey accounts_data column length when inserting and searching #29926
Conversation
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
/backport to stable23 |
public static function shortenMultibyteString(string $subject, int $dataLength, int $accuracy = 5): string { | ||
$temp = mb_substr($subject, 0, $dataLength); | ||
// json encodes encapsulates the string in double quotes, they need to be substracted | ||
while ((strlen(json_encode($temp)) - 2) > $dataLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there scenarios where the while loop never ends ? maybe check if $oldTemp != $temp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when you provide $accuracy with <= $dataLength * -1
Can you leave a comment in notifications to move to the utility function? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌👌
Failure unrelated |
|
This was caught with the following scenario:
Solution: since this table is only used for searching phone numbers and additional email currently, it is save to cut off the value that is being written there. To ensure searches work, we prepare the values accordingly. The shortener is taken and adjusted from https://github.com/nextcloud/notifications/blob/67aae02222755d0c7672c634bdfce3859be117b1/lib/Push.php#L485-L491.