~dricottone/mail-filters

616ddf99062b278494219a7dc8c893fe730d2f11 — Dominic Ricottone 4 years ago 9302fb1
Change to handling header section of debian mail
1 files changed, 14 insertions(+), 8 deletions(-)

M src/debian.awk
M src/debian.awk => src/debian.awk +14 -8
@@ 24,23 24,29 @@ BEGIN {

  else {
    # identify header section
    if (in_header==1 && $0 ~ /^-\s+-{5,}/) in_header=0;
    else if ($0 ~ /^-\s+-{5,}/) in_header=1;
    if (in_header==1 && $0 ~ /^-\s+-{5,}/ || $0 ~ /^\s*$/) in_header=0;
    else if ($0 ~ /^(-\s+-{5,}|(Package|CVE ID)\s*:)/) in_header=1;

    if (in_header==1) {
      if ($0 !~ /^-/) {
      if ($0 ~ /^Package\s*:/) {
        whitespace=substr("                ",length($1)+3)
        $3=whitespace dim cyan $3;
        $0=$0 reset;
      }
      else if ($0 ~ /^CVE ID\s*:/) {
        whitespace=substr("                ",length($1)+length($2)+4)
        $4=whitespace dim cyan $4;
        $0=$0 reset;
      }
      else if ($0 !~ /^-/) {
        $0=dim cyan $0 reset;
      }
    }
    else {
      if ($0 ~ /^(Package|Mailing list)\s*:/) {
      if ($0 ~ /^Mailing list:/) {
        $3=dim cyan $3;
        $0=$0 reset;
      }
      else if ($0 ~ /^(CVE ID)\s*:/) {
        $4=dim cyan $4;
        $0=$0 reset;
      }
      for (i in releases) {
        replacement=yellow releases[i] reset;
        gsub(releases[i],replacement);