diff options
author | zeripath <art27@cantab.net> | 2022-01-07 01:18:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 02:18:52 +0100 |
commit | 21ed4fd8da4c8992518dcfb01aa7306f7406f735 (patch) | |
tree | eb0bdaed8d06849116818f058b6120633d329d69 /templates/repo/wiki | |
parent | ee60f27aec0f75a34ae62841ed52579c0c20dcfa (diff) | |
download | gitea-21ed4fd8da4c8992518dcfb01aa7306f7406f735.tar.gz gitea-21ed4fd8da4c8992518dcfb01aa7306f7406f735.zip |
Add warning for BIDI characters in page renders and in diffs (#17562)
Fix #17514
Given the comments I've adjusted this somewhat. The numbers of characters detected are increased and include things like the use of U+300 to make à instead of à and non-breaking spaces.
There is a button which can be used to escape the content to show it.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Gwyneth Morgan <gwymor@tilde.club>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'templates/repo/wiki')
-rw-r--r-- | templates/repo/wiki/view.tmpl | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl index b71c950e17..db0ce14878 100644 --- a/templates/repo/wiki/view.tmpl +++ b/templates/repo/wiki/view.tmpl @@ -45,6 +45,10 @@ </div> </div> <div class="eight wide right aligned column"> + {{if .EscapeStatus.Escaped}} + <a class="ui small button unescape-button" style="display: none;">{{.i18n.Tr "repo.unescape_control_characters"}}</a> + <a class="ui small button escape-button">{{.i18n.Tr "repo.escape_control_characters"}}</a> + {{end}} {{if and .CanWriteWiki (not .Repository.IsMirror)}} <div class="ui right"> <a class="ui small button" href="{{.RepoLink}}/wiki/{{.PageURL}}?action=_edit">{{.i18n.Tr "repo.wiki.edit_page_button"}}</a> @@ -61,26 +65,29 @@ </div> {{end}} <div class="ui {{if .sidebarPresent}}grid equal width{{end}}" style="margin-top: 1rem;"> - <div class="ui {{if .sidebarPresent}}eleven wide column{{end}} segment markup"> - {{.content | Str2html}} + <div class="ui {{if .sidebarPresent}}eleven wide column{{end}} segment markup wiki-content-main"> + {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}} + {{.content | Safe}} </div> {{if .sidebarPresent}} <div class="column" style="padding-top: 0;"> - <div class="ui segment"> + <div class="ui segment wiki-content-sidebar"> {{if and .CanWriteWiki (not .Repository.IsMirror)}} <a class="ui right floated muted" href="{{.RepoLink}}/wiki/_Sidebar?action=_edit" aria-label="{{.i18n.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a> {{end}} - {{.sidebarContent | Str2html}} + {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .sidebarEscapeStatus "root" $}} + {{.sidebarContent | Safe}} </div> </div> {{end}} </div> {{if .footerPresent}} - <div class="ui segment"> - {{if and .CanWriteWiki (not .Repository.IsMirror)}} - <a class="ui right floated muted" href="{{.RepoLink}}/wiki/_Footer?action=_edit" aria-label="{{.i18n.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a> - {{end}} - {{.footerContent | Str2html}} + <div class="ui segment wiki-content-footer"> + {{if and .CanWriteWiki (not .Repository.IsMirror)}} + <a class="ui right floated muted" href="{{.RepoLink}}/wiki/_Footer?action=_edit" aria-label="{{.i18n.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a> + {{end}} + {{template "repo/unicode_escape_prompt" dict "footerEscapeStatus" .sidebarEscapeStatus "root" $}} + {{.footerContent | Safe}} </div> {{end}} </div> |