-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
ERROR: invalid character '\n' in string literal #6793
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
Comments
Hmm this is more interesting than that. The issue appears to be when unmarshalling some JSON - I suspect somewhere we're writing JSON by hand instead of using marshal, I wouldn't be surprised if " weren't being properly escaped and you could inject other attributes. I don't think this is exploitable hence my explicit mentioning of this but it's certainly not good. The problem is that the log message is not very helpful - the error is coming from within internal go code. Is there any more information nearby to help identify the naughty code? Have you been able to reproduce on master? |
So the likely source of the error message is: gitea/modules/templates/helper.go Lines 426 to 433 in c8fc7fc
in particular: gitea/modules/templates/helper.go Line 429 in c8fc7fc
The funny thing is why is |
ActionContent2Commits is used on the feeds screen: gitea/templates/user/dashboard/feeds.tmpl Lines 62 to 74 in c8fc7fc
So I should focus at these two types of action |
Line 630 in c8fc7fc
|
Line 840 in c8fc7fc
hmm... |
OK I don't understand - there doesn't seem to be any way this can happen unless the Action table contents have somehow been changed. Have you migrated from a different database format? Do you have some unusual SQLServer options set? |
Thanks for looking into this @zeripath. I did indeed migrate from NoSQL to MySQL, following this guide. Essentially I used Sorry, I didn't realise it was relevant. I've edited the opening post to reflect this. Looking at the Action table, this seems to be relevant entry:
Notice the extra "\n" in the commit message field. I looked at my backup from
So it looks the problem is how |
Ok, so it looks like dump is the cause of this - it really needs a thorough check up and I suspect that it's thoroughly broken - (I've been avoiding it because I know I'll need to learn how xorm works properly and there are plenty of other bugs that have my attention elsewhere.) To fix your immediate problem you need to change those explicit '\n' to escaped '\\n' in your database. I think there are two options for how to proceed with this issue: either rename this issue, or close and reopen a new one explicitly mentioning dump as the cause. |
Thanks, I've renamed the issue as you suggested. In the meanwhile, I'll fix the '\n's directly in the database. |
I just realised that this still happens for actions that occured after the database tranfer!
|
Hmm. So you're getting the unmarshalling error for these commits too? Right, confirm for me what database you're using. Is it mysql or mssql? I can't repeat this on MSSQL or sqlite. |
If you're definitely getting unmarshalling errors for these commits I'm highly suspicious that mysql (or at least your mysql instance) is unescaping things either when it's being read or it is being inserted. Do me a favour test some commits that have backslashes in them and perhaps other places e.g. repository description. So that would be add a literal |
I'm using MySQL. I created a test commit with some special characters, and they seem to be escaped correctly:
I tried a few other commits with special characters, they all seem to work now. Please ignore my previous message. I upgraded to v1.8.1 a couple of days ago, may be that fixed it? I'll close this issue and will create a new one about |
Cool. Thanks for looking at this. |
Uh oh!
There was an error while loading. Please reload this page.
[x]
):Description
It looks like gitea doesn't cope well with LF chacracters in a commit message. I regularly get the following in my gitea log:
Edit: Turns out this is because the gitea dump doesn't escape some special characters, see below.
The text was updated successfully, but these errors were encountered: