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/diff/section_unified.tmpl | |
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/diff/section_unified.tmpl')
-rw-r--r-- | templates/repo/diff/section_unified.tmpl | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 74634a760f..93f9af52b4 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -25,16 +25,29 @@ <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td> <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td> {{end}} + {{$inlineDiff := $section.GetComputedInlineDiffFor $line -}} + <td class="lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{$.i18n.Tr "repo.line_unicode"}}"></a>{{end}}</td> <td class="lines-type-marker"><span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> {{if eq .GetType 4}} - <td class="chroma lines-code blob-hunk"><code class="code-inner">{{$section.GetComputedInlineDiffFor $line}}</code></td> + <td class="chroma lines-code blob-hunk">{{/* + */}}<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{$.root.i18n.Tr "repo.line_unicode"}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code>{{/* + */}} + {{$line.Content}} + </td> {{else}} - <td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{if and $.root.SignedUserID $.root.PageIsPullFiles}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{svg "octicon-plus"}}</a>{{end}}<code class="code-inner">{{$section.GetComputedInlineDiffFor $line}}</code></td> + <td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/* + */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* + */}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/* + */}}{{svg "octicon-plus"}}{{/* + */}}</a>{{/* + */}}{{end}}{{/* + */}}<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{$.root.i18n.Tr "repo.line_unicode"}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code>{{/* + */}}</td> {{end}} </tr> {{if gt (len $line.Comments) 0}} <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}"> - <td colspan="2" class="lines-num"></td> + <td colspan="3" class="lines-num"></td> <td class="add-comment-left add-comment-right" colspan="2"> {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} </td> |