Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Haskell
id: setup-haskell-cabal
uses: actions/setup-haskell@v1.1.3
uses: haskell-actions/setup@v2
with:
ghc-version: 8.8
ghc-version: 9.8.4

- name: Cabal Check
run: cabal check
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
cabal: ["3.2"]
ghc: ["8.6.5", "8.8.4", "8.10.2"]
cabal: ["3.12.1.0"]
ghc: ["9.6.7", "9.8.4", "9.10.2"]
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Haskell
id: setup-haskell-cabal
uses: actions/setup-haskell@v1.1.3
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
Expand All @@ -28,7 +28,7 @@ jobs:
cabal freeze

- name: Cache ~/.cabal/store
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
Expand All @@ -40,7 +40,7 @@ jobs:
run: cabal test

- name: Upload Build Logs on Failure
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: logs-${{ matrix.os }}-ghc${{ matrix.ghc }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/TAGS
/.stack-work/
/.cabal/
dist-newstyle/
*.local
26 changes: 13 additions & 13 deletions addy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ copyright: Copyright (c) 2019-2020 Peter Jones
homepage: https://github.com/pjones/addy
bug-reports: https://github.com/pjones/addy/issues
category: Text
tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2
tested-with: GHC ==9.4.8 || ==9.6.7 || ==9.8.4 || ==9.10.2
build-type: Simple
synopsis:
A full-featured library for parsing, validating, and rendering email addresses
Expand Down Expand Up @@ -71,15 +71,15 @@ common options
--------------------------------------------------------------------------------
common dependencies
build-depends:
, attoparsec ^>=0.13
, base >=4.9 && <5.0
, bytestring >=0.10 && <0.12
, ip >=1.5.1 && <1.8
, lens >=4.17 && <5.0
, relude >=0.6 && <0.8
, text ^>=1.2
, text-icu ^>=0.7
, validation-selective ^>=0.1
, attoparsec >=0.13 && <0.15
, base >=4.9 && <5.0
, bytestring >=0.10 && <0.13
, ip >=1.5.1 && <1.8
, lens >=4.17 && <5.4
, relude >=0.6 && <2.0
, text >=1.2 && <3.0
, unicode-transforms >=0.4.0.1 && <0.5
, validation-selective >=0.1.0.0 && <0.3

mixins:
base hiding (Prelude),
Expand Down Expand Up @@ -111,11 +111,11 @@ test-suite test
build-depends:
, addy
, aeson >=1.4
, hedgehog ^>=1.0
, hedgehog >=1.0 && <2.0
, http-types >=0.12
, tasty >=1.1 && <1.5
, tasty-hedgehog ^>=1.0
, tasty-hunit ^>=0.10
, tasty-hedgehog >=1.0 && <1.5
, tasty-hunit >=0.10 && <0.11

--------------------------------------------------------------------------------
-- test-suite doctests
Expand Down
9 changes: 6 additions & 3 deletions src/Addy/Internal/Validation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ where

import Addy.Internal.Char
import Addy.Internal.Types


import qualified Data.ByteString as ByteString
import qualified Data.Text as Text
import qualified Data.Text.ICU as ICU

import Data.Text.Normalize (NormalizationMode(..), normalize)
import Validation

-- | Validate a single host name. Each host name in a domain name
Expand All @@ -57,7 +60,7 @@ import Validation
-- @since 0.1.0.0
validateHostName :: Text -> Validation (NonEmpty Error) HostName
validateHostName content =
let content' = Text.toLower (ICU.normalize ICU.NFC content)
let content' = Text.toLower $ normalize NFC content
in HN content'
<$ ( validateNotPrefix "-" content'
*> validateNotSuffix "-" content'
Expand Down Expand Up @@ -100,7 +103,7 @@ validateDomainName name =
validateLocalPart ::
Text -> Validation (NonEmpty Error) LocalPart
validateLocalPart content =
let content' = ICU.normalize ICU.NFC content
let content' = normalize NFC content
in LP content'
<$ ( validateLength 1 64 content'
*> validateAllowedChars allowedChar content'
Expand Down
11 changes: 7 additions & 4 deletions test/TestData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ data IsEmailCat
isEmailTests :: IO [(IsEmailTest, IsEmailCat)]
isEmailTests = do
let fileName = "test/isemail.json"
tests <- (Aeson.decode <$> readFileLBS fileName) >>= \case
Nothing -> assertFailure "failed to load the isemail.json file"
Just ts -> pure ts
tests <- readFileLBS fileName
>>=
(\case
Nothing -> assertFailure "failed to load the isemail.json file"
Just ts -> pure ts)
. Aeson.decode
pure $ map (\t -> (decodeAddr t, decodeCat t)) tests

-- | The XSL file URL-encodes the email addresses. Additionally, the
Expand Down Expand Up @@ -229,7 +232,7 @@ allowedChar c = isAscii c || utf8NonAscii c
unicode :: Gen Char
unicode =
Gen.frequency
[ (55296, Gen.element "!#$%&'*+-/=?^_`{|}~"),
[ (55296, Gen.element ("!#$%&'*+-/=?^_`{|}~" :: String)),
(55296, Gen.alphaNum),
(8190, Gen.filter isPrint (Gen.enum (chr 0xc2) maxBound))
]