-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
fix truncate utf8 string #15828
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
fix truncate utf8 string #15828
Conversation
Test case:
then update settings |
Codecov Report
@@ Coverage Diff @@
## main #15828 +/- ##
==========================================
+ Coverage 43.92% 44.00% +0.07%
==========================================
Files 681 681
Lines 82228 82239 +11
==========================================
+ Hits 36120 36190 +70
+ Misses 40205 40143 -62
- Partials 5903 5906 +3
Continue to review full report at Codecov.
|
Suggest move this change to a new pull request, Thanks. |
I dont think we need a sec pull for this nit. Throu when backporting we should only backport the fix |
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.
blocked
I think we need to be careful allowing arbitary length descriptions, websites and locations for users. These fields are often read in and the user objects passed around. Realistically these fields should be dropped from the user table itself and only read in when they're actually needed but as this stands this PR represents a serious threat to the stability of Gitea on large installs. |
ok as of state of this pull now, @palytoxin the best way is to splitt it so we can discust on both things seperatly |
I modified this pr so that it's only changed the truncation func in |
Sorry about that @palytoxin - it would be fine to make it a config option with the current default but realistically these fields shouldn't be in models.User. They need to be in some other table models.Settings or Config or UserConfig. Most of the time we're loading the user object we do not want or care about the contents of the location or description attributes and it's fine to load them if they're small but if you're allowing them to get big well ... Then we need to move them off of user. |
yes, I got. bug move them off of user may need to be modified by someone who knows more about this project, otherwise it makes new bugs. But these columns have been validated before saving(in form valid ). Line 54 in dd81c29
|
@palytoxin please "update" this pull or allow maintainer to do so :) |
@6543 Please check it ;D |
@palytoxin Please send backport to v1.14 |
Backport go-gitea#15828 * fix truncate utf8 string. * revoke truncated user info.
I've sent the backport for you @palytoxin . If you would rather have the PR under your name please feel free to send another backport PR and we can close the one I've opened. |
Backport #15828 * fix truncate utf8 string. * revoke truncated user info. Co-authored-by: yan <[email protected]>
@zeripath It's all right. |
* fix truncate utf8 string. * revoke truncated user info.
I removed the truncate operation before updating because it goes through the form validation before updating again. the truncate operation is redundant.And I fixed the problem of truncating utf8 strings, in special cases, the truncation operation would cause the database storage to fail to detect the encoding