1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{{/*
  Rendering of one correspondent's name, shared by every HTML view.

  The distinction it draws is the same one the text renderings draw with ~ and
  quotes: a petname was assigned here and is vouched for, a display name came
  out of a From: header and is a claim by whoever sent the mail. This archive
  contains "Deutsche-Baпk AG" with a Cyrillic п, and "Ζaκaria" in Greek letters
  arriving through GitHub, both of which used to render exactly like a name the
  reader had chosen.

  It is one defined template rather than markup repeated in each view because
  the marking is a security property: four copies are four chances for one of
  them to quietly print a bare .Claimed, which is the state this replaced.

  "name" renders the name alone; "nameAddr" adds the address beneath it, for
  the places with room for two lines.
*/}}
{{define "name"}}
  {{- if .Petname -}}
    <span class="pet" title="A name you assigned to {{.Address}}. Local to mailweb and never sent.">{{.Petname}}</span>
  {{- else if .Claimed -}}
    <span class="claimed" title="Written by the sender and not verified by anything.">&ldquo;{{.Claimed}}&rdquo;</span>
    {{- if .Mixed}} <span class="mixed" title="This name mixes alphabets inside a single word — Latin with Cyrillic or Greek — which is how a lookalike name is built. It is not proof of anything, but it is worth a second look at the address.">mixed alphabets</span>{{end -}}
  {{- else -}}
    <span class="claimed">{{.Address}}</span>
  {{- end -}}
{{end}}

{{define "nameAddr"}}
  {{- template "name" . -}}
  {{- if or .Petname .Claimed}}<br><span class="addr-line">{{.Address}}</span>{{end -}}
{{end}}

{{define "nameStyle"}}
  .pet     { font-weight: 600; }
  .claimed { font-weight: normal; color: var(--text-meta); font-style: italic; }
  .addr-line { color: var(--text-meta); font-size: 0.85em; }
  .mixed {
    font-size: 0.75em; color: var(--danger, #c0392b);
    border: 1px solid currentColor; border-radius: 3px;
    padding: 0 0.25em; white-space: nowrap; font-style: normal;
  }
{{end}}