Skip to content

Commit

Permalink
Allow <> in name
Browse files Browse the repository at this point in the history
  • Loading branch information
cesartw committed Dec 11, 2023
1 parent 67b2155 commit 4936608
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 262 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Checks

on:
pull_request:

env:
GOPRIVATE: github.com/teamwork/*
GOFLAGS: -mod=readonly
LANG: en_US.UTF-8

jobs:
lint:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21"

- name: Setup git
run: git config --global url."https://[email protected]/".insteadOf "https://github.com/"

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
only-new-issues: true
args: "--out-${NO_FUTURE}format colored-line-number"

test:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21"

- name: Setup git
run: git config --global url."https://[email protected]/".insteadOf "https://github.com/"

- name: Test
run: |
go mod tidy
go test -coverprofile=full.coverage -race -count=1 ./...
- name: Generate diff
run: |
git diff origin/${{ github.base_ref }}...origin/${{ github.head_ref }} > pr.diff
- name: Compute new code coverage
id: covdiffaction
uses: panagiotisptr/[email protected]
with:
path: .
coverprofile: full.coverage
diff: pr.diff
module: github.com/teamwork/mailaddress

- name: Comment
uses: mshick/add-pr-comment@v2
with:
message: |
Coverage on new code: ${{ steps.covdiffaction.outputs.covdiff }}%
18 changes: 18 additions & 0 deletions .github/workflows/teamwork.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: teamwork

on:
pull_request:
types: [opened, closed]
pull_request_review:
types: [submitted]

jobs:
teamwork-sync:
runs-on: ubuntu-latest
name: Teamwork Sync
steps:
- uses: teamwork/github-sync@master
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEAMWORK_URI: ${{ secrets.TEAMWORK_DC_URI }}
TEAMWORK_API_TOKEN: ${{ secrets.TEAMWORK_GHA_USER_TOKEN }}
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestStringEncoded(t *testing.T) {
{`[email protected]`, `[email protected]`},
{`Martin Tournoij <[email protected]>`, `Martin Tournoij <[email protected]>`},
{`"Martin Tournoij" <[email protected]>`, `Martin Tournoij <[email protected]>`},
{`Martin Tour<noij> <[email protected]>`, `Martin Tour noij <[email protected]>`},
{
`a العَرَبِي b <[email protected]>`,
`=?utf-8?q?a_=D8=A7=D9=84=D8=B9=D9=8E=D8=B1=D9=8E=D8=A8=D9=90=D9=8A_b?= <[email protected]>`,
Expand Down
58 changes: 0 additions & 58 deletions bin/coverage

This file was deleted.

59 changes: 0 additions & 59 deletions bin/lint

This file was deleted.

18 changes: 0 additions & 18 deletions bin/setup-travis

This file was deleted.

87 changes: 0 additions & 87 deletions bin/start

This file was deleted.

22 changes: 0 additions & 22 deletions bin/test

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/teamwork/mailaddress

go 1.16
go 1.21

require (
github.com/davecgh/go-spew v1.1.0 // indirect
Expand Down
7 changes: 7 additions & 0 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ func parse(str string) (list List, haveError bool) {
// End <angl-addr>
case !inQuote && chr == ">":
addr.Raw += ">"
// we've observed name including `<>`
if i < len(str)-1 && !addr.Valid() {
addr.Name += " " + addr.Address
addr.Address = ""
addr.err = nil // valid is not idempoent
}

inAddress = false

// Next <address>
Expand Down
2 changes: 1 addition & 1 deletion parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Tournoij

func TestInvalid(t *testing.T) {
for i, test := range invalidAddresses {
t.Run(fmt.Sprintf("%v", i), func(t *testing.T) {
t.Run(fmt.Sprintf("%d_%s", i, test), func(t *testing.T) {
out, err := Parse(test)
if out.Valid() {
t.Fatal("out.Valid() said it was valid.")
Expand Down

0 comments on commit 4936608

Please sign in to comment.