We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
[x]
If the file is readme.txt and the encoding is not UTF-8, the file rendering displays the garbled code. The reason for the garbled is that it has not been converted to UTF-8. The code is as follows: https://github.com/go-gitea/gitea/blob/master/routers/repo/view.go#L214
The solutions are as follows: Change lines 211-248 into:
} else { // Building code view blocks with line number on server side. var fileContent string if content, err := templates.ToUTF8WithErr(buf); err != nil { if err != nil { log.Error(4, "ToUTF8WithErr: %v", err) } fileContent = string(buf) } else { fileContent = content } if readmeExist { ctx.Data["IsRenderedHTML"] = true ctx.Data["FileContent"] = strings.Replace( gotemplate.HTMLEscapeString(fileContent), "\n", `<br>`, -1, ) } else { var output bytes.Buffer lines := strings.Split(fileContent, "\n") //Remove blank line at the end of file if len(lines) > 0 && lines[len(lines)-1] == "" { lines = lines[:len(lines)-1] } for index, line := range lines { line = gotemplate.HTMLEscapeString(line) if index != len(lines)-1 { line += "\n" } output.WriteString(fmt.Sprintf(`<li class="L%d" rel="L%d">%s</li>`, index+1, index+1, line)) } ctx.Data["FileContent"] = gotemplate.HTML(output.String()) output.Reset() for i := 0; i < len(lines); i++ { output.WriteString(fmt.Sprintf(`<span id="L%d">%d</span>`, i+1, i+1)) } ctx.Data["LineNums"] = gotemplate.HTML(output.String()) } }
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
[x]
):Description
If the file is readme.txt and the encoding is not UTF-8, the file rendering displays the garbled code.
The reason for the garbled is that it has not been converted to UTF-8.
The code is as follows:
https://github.com/go-gitea/gitea/blob/master/routers/repo/view.go#L214
The solutions are as follows:
Change lines 211-248 into:
Screenshots
The text was updated successfully, but these errors were encountered: