-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 commenting on non-utf8 encoded files #11916
Fix commenting on non-utf8 encoded files #11916
Conversation
9c71bfa
to
77cb452
Compare
Hmm... seems like Blob won't work without adding functions to convert between blob and text. In which case we may as well keep it as TEXT and just escape the bad chars. |
You should change struct Patch to byte array instead of string |
0d9611e
to
cb9374d
Compare
I think the simplest thing is to shadow the Patch column and quote/unquote as necessary. |
Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
d7c5f4f
to
015f9ce
Compare
Can't we just convert to UTF-8 when saving if it is not valid UTF-8 like we do it for displaying with detect encoding? |
So I've thought about that but: a) We don't have a long enough piece of text to detect the encoding and we can't assume that we will always be enable to detect the encoding. Keeping the broken bytes is really better as we can use them to improve our rendering in future. |
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.
to fix it this is totaly ok - we should just konsiddert to refactor&improve this at some point
🚀 |
I'll send a backport |
* Add comment on non-unicode line to force fail Signed-off-by: Andrew Thornton <[email protected]> * Just quote/unquote patch Signed-off-by: Andrew Thornton <[email protected]>
* Add comment on non-unicode line to force fail Signed-off-by: Andrew Thornton <[email protected]> * Just quote/unquote patch Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: zeripath <[email protected]>
* Add comment on non-unicode line to force fail Signed-off-by: Andrew Thornton <[email protected]> * Just quote/unquote patch Signed-off-by: Andrew Thornton <[email protected]>
The original implementation of models.Comment.Patch maps this to an SQL TEXT field. This works fine when the line being commented on is UTF-8 however, if there are non-UTF-8 characters this fails on MySQL and PostgreSQL databases.
This PR changes this field to quote it if necessary.
Signed-off-by: Andrew Thornton [email protected]