Skip to content

Conversation

@bentolor
Copy link
Contributor

Fix courtesty due to @D-side

This issue occurs when 100 bytes past the start of the note is inside
a UTF-8 multibyte character. E. g. if a note is comprised of 99
single-bytes and 100th multibyte.

This is very easy to hit in Russian, since it uses a Cyrillic charset
(2 bytes per UTF-8 char), but spaces and punctuation from ASCII
(1 byte each). But since the condition is so obscure, some texts
work and some don't seemingly at random (except not!).

Based on https://stackoverflow.com/q/9087502/ it seems that
using mb_substr with utf-8 seems to be the better approach

@bentolor
Copy link
Contributor Author

Quote a bunch of automated tests are failing but it seems due to a infrastructure problem, not my code change…

@korelstar korelstar added this to the 4.0.1 milestone Nov 22, 2020
@korelstar korelstar linked an issue Nov 22, 2020 that may be closed by this pull request
Copy link
Member

@korelstar korelstar left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution! Although I wasn't able to reproduce the issue, it's very reasonable that this will fix it. Before I merge this, please

@bentolor bentolor force-pushed the fix/dashboard-http500-nonasciinotest-issue-620 branch 2 times, most recently from e21c606 to c92cd67 Compare November 23, 2020 11:34
Fix courtesty due to @D-side

This issue occurs when 100 bytes past the start of the note is inside
a UTF-8 multibyte character. E. g. if a note is comprised of 99
single-bytes and 100th multibyte.

This is very easy to hit in Russian, since it uses a Cyrillic charset
(2 bytes per UTF-8 char), but spaces and punctuation from ASCII
(1 byte each). But since the condition is so obscure, some texts
work and some don't seemingly at random (except not!).

Based on https://stackoverflow.com/q/9087502/ it seems that
using  `mb_substr` with `utf-8` seems to be the better approach

Signed-off-by: Benjamin Schmid <bentolor@users.noreply.github.com>
As pointed out by @korelstar in his review, this should avoid
strange issues in handling truncation of UTF-8 encoded, potential
multibyte data streams

Signed-off-by: Benjamin Schmid <bentolor@users.noreply.github.com>
@bentolor bentolor force-pushed the fix/dashboard-http500-nonasciinotest-issue-620 branch from c92cd67 to 45444f1 Compare November 23, 2020 11:37
@bentolor
Copy link
Contributor Author

Thanks, @korelstar for your quick and helpful feedback.

I think I succeeded in adopting your proposed changes as well as mastering all the hurdles to get my MR ready for integration!

Thank you again for you quick feedback!

@korelstar korelstar merged commit a4a282c into nextcloud:master Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP 500 error in Dashboard

2 participants