Skip to content

Consider ordering of tag-value pairs; ignore unknown tags#6

Closed
ryansch wants to merge 1 commit intomasterfrom
order-matters
Closed

Consider ordering of tag-value pairs; ignore unknown tags#6
ryansch wants to merge 1 commit intomasterfrom
order-matters

Conversation

@ryansch
Copy link
Copy Markdown
Contributor

@ryansch ryansch commented Aug 12, 2014

From the spec:

A DMARC policy record MUST comply with the formal specification found
in Section 5.3 in that the "v" and "p" tags MUST be present and MUST
appear in that order.  Unknown tags MUST be ignored.  Syntax errors
in the remainder of the record SHOULD be discarded in favor of
default values (if any) or ignored outright.

We are currently enforcing the order of all of the tags (not just v and p). We also blow up on unknown tags.

I've added a failing test with yahoo's dmarc record as an example of the pct tag being out of order.

@postmodern
Copy link
Copy Markdown
Contributor

So we need to move back to the Array of Hashes model? For unknown tags, we could add a catch rule. Not sure how we'd safely recover from syntax errors within tags. Maybe we'd have to split by ';' first, and parse each tag individually?

@ryansch
Copy link
Copy Markdown
Contributor Author

ryansch commented Aug 14, 2014

I'm not sure. I'm heads down on some other stuff for the rest of the week. I'll have another look early next week.

@ryansch
Copy link
Copy Markdown
Contributor Author

ryansch commented Aug 14, 2014

I've reached out to the parslet community on the mailing list for ideas.

@ryansch
Copy link
Copy Markdown
Contributor Author

ryansch commented Aug 15, 2014

Possible example:

rule(:a) { a_properly_formed_a | consume_anything_upto_the_next_tag_start } 
rule(:consume_anything_upto_the_next_tag_start) {  (start_tag_token.absent? >> any).repeat(1) }

@postmodern
Copy link
Copy Markdown
Contributor

Ah clever. Instead of any how about match["^#{dmarc_sep}"].repeat(1)?

@postmodern
Copy link
Copy Markdown
Contributor

Closing/Recreating this now that we have the Alexa Top 500 gauntlet tests.

@postmodern postmodern closed this Sep 5, 2014
@ryansch ryansch deleted the order-matters branch October 10, 2014 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants