summaryrefslogtreecommitdiffstats
path: root/web_src/less
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-01-07 01:18:52 +0000
committerGitHub <noreply@github.com>2022-01-07 02:18:52 +0100
commit21ed4fd8da4c8992518dcfb01aa7306f7406f735 (patch)
treeeb0bdaed8d06849116818f058b6120633d329d69 /web_src/less
parentee60f27aec0f75a34ae62841ed52579c0c20dcfa (diff)
downloadgitea-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 'web_src/less')
-rw-r--r--web_src/less/_base.less10
-rw-r--r--web_src/less/_repository.less43
-rw-r--r--web_src/less/_review.less11
3 files changed, 64 insertions, 0 deletions
diff --git a/web_src/less/_base.less b/web_src/less/_base.less
index 741efeadca..c19030cccf 100644
--- a/web_src/less/_base.less
+++ b/web_src/less/_base.less
@@ -668,6 +668,12 @@ a.ui.card:hover,
color: var(--color-text-dark);
}
+.ui.error.message .header,
+.ui.warning.message .header {
+ color: inherit;
+ filter: saturate(2);
+}
+
.dont-break-out {
overflow-wrap: break-word;
word-wrap: break-word;
@@ -1569,6 +1575,10 @@ a.ui.label:hover {
}
}
+.lines-escape {
+ width: 0;
+}
+
.lines-code {
background-color: var(--color-code-bg);
padding-left: 5px;
diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less
index 7320f3e302..4894a0a2c9 100644
--- a/web_src/less/_repository.less
+++ b/web_src/less/_repository.less
@@ -76,6 +76,24 @@
}
}
+ .unicode-escaped .escaped-code-point {
+ &[data-escaped]::before {
+ visibility: visible;
+ content: attr(data-escaped);
+ font-family: var(--fonts-monospace);
+ color: var(--color-red);
+ }
+
+ .char {
+ display: none;
+ }
+ }
+
+ .broken-code-point {
+ font-family: var(--fonts-monospace);
+ color: blue;
+ }
+
.metas {
.menu {
overflow-x: auto;
@@ -3020,6 +3038,26 @@ td.blob-excerpt {
padding-left: 8px;
}
+.ui.message.unicode-escape-prompt {
+ margin-bottom: 0;
+ border-radius: 0;
+ display: flex;
+ flex-direction: column;
+}
+
+.wiki-content-sidebar .ui.message.unicode-escape-prompt,
+.wiki-content-footer .ui.message.unicode-escape-prompt {
+ p {
+ display: none;
+ }
+}
+
+/* fomantic's last-child selector does not work with hidden last child */
+.ui.buttons .unescape-button {
+ border-top-right-radius: .28571429rem;
+ border-bottom-right-radius: .28571429rem;
+}
+
.webhook-info {
padding: 7px 12px;
margin: 10px 0;
@@ -3110,6 +3148,7 @@ td.blob-excerpt {
.code-diff-unified .del-code,
.code-diff-unified .del-code td,
.code-diff-split .del-code .lines-num-old,
+.code-diff-split .del-code .lines-escape-old,
.code-diff-split .del-code .lines-type-marker-old,
.code-diff-split .del-code .lines-code-old {
background: var(--color-diff-removed-row-bg);
@@ -3120,9 +3159,11 @@ td.blob-excerpt {
.code-diff-unified .add-code td,
.code-diff-split .add-code .lines-num-new,
.code-diff-split .add-code .lines-type-marker-new,
+.code-diff-split .add-code .lines-escape-new,
.code-diff-split .add-code .lines-code-new,
.code-diff-split .del-code .add-code.lines-num-new,
.code-diff-split .del-code .add-code.lines-type-marker-new,
+.code-diff-split .del-code .add-code.lines-escape-new,
.code-diff-split .del-code .add-code.lines-code-new {
background: var(--color-diff-added-row-bg);
border-color: var(--color-diff-added-row-border);
@@ -3131,7 +3172,9 @@ td.blob-excerpt {
.code-diff-split .del-code .lines-num-new,
.code-diff-split .del-code .lines-type-marker-new,
.code-diff-split .del-code .lines-code-new,
+.code-diff-split .del-code .lines-escape-new,
.code-diff-split .add-code .lines-num-old,
+.code-diff-split .add-code .lines-escape-old,
.code-diff-split .add-code .lines-type-marker-old,
.code-diff-split .add-code .lines-code-old {
background: var(--color-diff-inactive);
diff --git a/web_src/less/_review.less b/web_src/less/_review.less
index 12bd6a608a..1070ad7dde 100644
--- a/web_src/less/_review.less
+++ b/web_src/less/_review.less
@@ -16,6 +16,17 @@
}
}
+.lines-escape a.toggle-escape-button::before {
+ visibility: visible;
+ content: '⚠️';
+ font-family: var(--fonts-emoji);
+ color: var(--color-red);
+}
+
+.repository .diff-file-box .code-diff td.lines-escape {
+ padding-left: 0 !important;
+}
+
.diff-file-box .lines-code:hover .ui.button.add-code-comment {
opacity: 1;
}