summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-01-28 06:23:31 +0800
committerGitHub <noreply@github.com>2024-01-27 23:23:31 +0100
commitb8e6cffd317401d980600e339eb21b15b9bc64c1 (patch)
tree7b8476c5931522c7c69938f8f7164f2f4970c3c3 /templates
parent1ddcaedb88bc9ea829df8df6b254c73615c70031 (diff)
downloadgitea-b8e6cffd317401d980600e339eb21b15b9bc64c1.tar.gz
gitea-b8e6cffd317401d980600e339eb21b15b9bc64c1.zip
Preserve BOM in web editor (#28935) (#28959)
Backport #28935 by @silverwind The `ToUTF8*` functions were stripping BOM, while BOM is actually valid in UTF8, so the stripping must be optional depending on use case. This does: - Add a options struct to all `ToUTF8*` functions, that by default will strip BOM to preserve existing behaviour - Remove `ToUTF8` function, it was dead code - Rename `ToUTF8WithErr` to `ToUTF8` - Preserve BOM in Monaco Editor - Remove a unnecessary newline in the textarea value. Browsers did ignore it, it seems but it's better not to rely on this behaviour. Fixes: https://github.com/go-gitea/gitea/issues/28743 Related: https://github.com/go-gitea/gitea/issues/6716 which seems to have once introduced a mechanism that strips and re-adds the BOM, but from what I can tell, this mechanism was removed at some point after that PR. Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/editor/edit.tmpl3
1 files changed, 1 insertions, 2 deletions
diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl
index 58ed6f356e..cfc266731b 100644
--- a/templates/repo/editor/edit.tmpl
+++ b/templates/repo/editor/edit.tmpl
@@ -38,8 +38,7 @@
data-url="{{.Repository.Link}}/markup"
data-context="{{.RepoLink}}"
data-previewable-extensions="{{.PreviewableExtensions}}"
- data-line-wrap-extensions="{{.LineWrapExtensions}}">
-{{.FileContent}}</textarea>
+ data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea>
<div class="editor-loading is-loading"></div>
</div>
<div class="ui bottom attached tab segment markup" data-tab="preview">