Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utilities to decide Purported Responsible Domain (http://www.ietf.org/rfc/rfc4407.txt).
- data PRD
- initialPRD :: PRD
- pushPRD :: RawFieldKey -> RawFieldValue -> PRD -> PRD
- decidePRD :: PRD -> Maybe Domain
- decideFrom :: PRD -> Maybe Domain
- extractDomain :: RawFieldValue -> Maybe Domain
Documentation
Abstract type for context to decide PRD(purported responsible domain) according to RFC 4407.
initialPRD :: PRD Source #
Initial context of PRD.
pushPRD :: RawFieldKey -> RawFieldValue -> PRD -> PRD Source #
Pushing a field key and its value in to the PRD context.
decidePRD :: PRD -> Maybe Domain Source #
Deciding PRD from the RPD context.
>>>
let maddr1 = "alice@alice.example.jp"
>>>
let maddr2 = "bob@bob.example.jp"
>>>
let maddr3 = "chris@chris.example.jp"
>>>
let maddr4 = "dave@dave.example.jp"
>>>
decidePRD (pushPRD "from" "alice@alice.example.jp" initialPRD)
Just "alice.example.jp">>>
:{
decidePRD (pushPRD "from" maddr1 $ pushPRD "from" maddr1 initialPRD) :} Nothing
>>>
:{
decidePRD (pushPRD "sender" maddr2 $ pushPRD "from" maddr1 $ pushPRD "from" maddr1 initialPRD) :} Just "bob.example.jp"
>>>
:{
decidePRD (pushPRD "sender" maddr2 $ pushPRD "sender" maddr2 $ pushPRD "from" maddr1 $ pushPRD "from" maddr1 initialPRD) :} Nothing
>>>
:{
decidePRD (pushPRD "resent-from" maddr3 $ pushPRD "sender" maddr2 $ pushPRD "sender" maddr2 $ pushPRD "from" maddr1 $ pushPRD "from" maddr1 initialPRD) :} Just "chris.example.jp"
>>>
:{
decidePRD (pushPRD "resent-sender" maddr4 $ pushPRD "resent-from" maddr3 $ pushPRD "sender" maddr2 $ pushPRD "sender" maddr2 $ pushPRD "from" maddr1 $ pushPRD "from" maddr1 initialPRD) :} Just "dave.example.jp"
>>>
:{
decidePRD (pushPRD "resent-sender" maddr4 $ pushPRD "resent-from" maddr3 $ pushPRD "sender" maddr2 $ pushPRD "received" "dummy" $ pushPRD "from" maddr1 initialPRD) :} Just "dave.example.jp"
>>>
:{
decidePRD (pushPRD "resent-sender" maddr4 $ pushPRD "received" "dummy" $ pushPRD "resent-from" maddr3 $ pushPRD "sender" maddr2 $ pushPRD "from" maddr1 initialPRD) :} Just "chris.example.jp"
>>>
:{
decidePRD (pushPRD "received" "dummy" $ pushPRD "resent-sender" maddr4 $ pushPRD "resent-from" maddr3 $ pushPRD "sender" maddr2 $ pushPRD "from" maddr1 initialPRD) :} Just "dave.example.jp"
decideFrom :: PRD -> Maybe Domain Source #
Taking the value of From: from the RPD context.
>>>
decideFrom (pushPRD "from" "alice@alice.example.jp" initialPRD)
Just "alice.example.jp"
extractDomain :: RawFieldValue -> Maybe Domain Source #
Extract a domain from a value of a header field.
>>>
extractDomain "Alice Brown <alice.brown@example.com>"
Just "example.com">>>
extractDomain "\"Alice . Brown\" <alice.brown@example.com> (Nickname here)"
Just "example.com">>>
extractDomain "alice.brown@example.com"
Just "example.com">>>
extractDomain "Alice Brown <example.com>"
Nothing