From ca195a25a7a8a4c1f7e593ed2a12a9ce1038c769 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sat, 21 Mar 2020 11:33:22 -0400 Subject: [PATCH] Borked code This needs to be fixed. --- lib/Parser/XML/Construct.php | 5 +- tests/cases/XML/feed-other.yaml | 208 ++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+), 2 deletions(-) diff --git a/lib/Parser/XML/Construct.php b/lib/Parser/XML/Construct.php index 1938878..607feec 100644 --- a/lib/Parser/XML/Construct.php +++ b/lib/Parser/XML/Construct.php @@ -196,8 +196,9 @@ abstract class Construct { $prefix = ($role === "webmaster") ? "$prefix:owner/$prefix" : $prefix; $out = new PersonCollection; $p = new Person; - $p->name = $this->fetchString("$prefix:author", ".+") ?? ""; - $p->mail = $this->fetchString("$prefix:email", "[^@]+@.+"); + $mail = $this->fetchString("$prefix:email") ?? ""; + $p->mail = $this->validateMail($mail) ? $mail : null; + $p->name = $this->fetchString("$prefix:name", ".+") ?? ""; $p->role = $role; if (strlen($p->name)) { $out[] = $p; diff --git a/tests/cases/XML/feed-other.yaml b/tests/cases/XML/feed-other.yaml index df20c1a..c23d3d1 100644 --- a/tests/cases/XML/feed-other.yaml +++ b/tests/cases/XML/feed-other.yaml @@ -139,3 +139,211 @@ Google Play categories: categories: - name: Arts - name: Music + +iTunes author 1: + input: > + + Jane Doe + jane.doe@example.com + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: author + +iTunes author 2: + input: > + + Jane Doe + bogus@example].com + + output: + format: rss + people: + - name: 'Jane Doe' + role: author + +iTunes author 3: + input: > + + + Jane Doe + jane.doe@example.com + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: author + +iTunes author 4: + input: > + + + jane.doe@example.com + + output: + format: rss + +iTunes owner 1: + input: > + + + Jane Doe + jane.doe@example.com + + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: webmaster + +iTunes owner 2: + input: > + + + Jane Doe + bogus@example].com + + + output: + format: rss + people: + - name: 'Jane Doe' + role: webmaster + +iTunes owner 3: + input: > + + + + Jane Doe + jane.doe@example.com + + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: webmaster + +iTunes owner 4: + input: > + + + + jane.doe@example.com + + + output: + format: rss + +Google Play author 1: + input: > + + Jane Doe + jane.doe@example.com + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: author + +Google Play author 2: + input: > + + Jane Doe + bogus@example].com + + output: + format: rss + people: + - name: 'Jane Doe' + role: author + +Google Play author 3: + input: > + + + Jane Doe + jane.doe@example.com + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: author + +Google Play author 4: + input: > + + + jane.doe@example.com + + output: + format: rss + +Google Play owner 1: + input: > + + + Jane Doe + jane.doe@example.com + + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: webmaster + +Google Play owner 2: + input: > + + + Jane Doe + bogus@example].com + + + output: + format: rss + people: + - name: 'Jane Doe' + role: webmaster + +Google Play owner 3: + input: > + + + + Jane Doe + jane.doe@example.com + + + output: + format: rss + people: + - name: 'Jane Doe' + mail: 'jane.doe@example.com' + role: webmaster + +Google Play owner 4: + input: > + + + + jane.doe@example.com + + + output: + format: rss