diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst
index 5d9f94fe..2143f182 100644
--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -29,3 +29,4 @@ bug report!
* `Aaron Swartz `_
* `Jakub Wilk `_
* `Nestor Rodriguez `_
+* `Roman Zubov `_
diff --git a/feedparser/mixin.py b/feedparser/mixin.py
index 3acee1b1..982d4de3 100644
--- a/feedparser/mixin.py
+++ b/feedparser/mixin.py
@@ -628,6 +628,14 @@ def pop(self, element, strip_whitespace=1):
else:
if element == "description":
element = "summary"
+
+ # Store the element in author/contributor dict when inside author
+ # context (for custom namespace elements)
+ author_context = self._maybe_get_author_context()
+ if author_context is not None:
+ author_context[element] = output
+ return output # Skip entry-level storage
+
old_value_depth = self.property_depth_map.setdefault(
self.entries[-1], {}
).get(element)
@@ -767,6 +775,16 @@ def _get_context(self):
context = self.feeddata
return context
+ def _maybe_get_author_context(self):
+ """Get current author/contributor dict if inside one, else None."""
+ if self.inentry:
+ entry = self.entries[-1]
+ if self.inauthor and entry.get("authors"):
+ return entry["authors"][-1]
+ if self.incontributor and entry.get("contributors"):
+ return entry["contributors"][-1]
+ return None
+
def _save_author(self, key, value, prefix="author"):
context = self._get_context()
context.setdefault(prefix + "_detail", FeedParserDict())
diff --git a/feedparser/namespaces/_base.py b/feedparser/namespaces/_base.py
index c3d01e9e..f474ebe3 100644
--- a/feedparser/namespaces/_base.py
+++ b/feedparser/namespaces/_base.py
@@ -146,8 +146,9 @@ def _start_author(self, attrs_d):
_start_managingeditor = _start_author
def _end_author(self):
- self.pop("author")
+ # Exit author context before pop()
self.inauthor = 0
+ self.pop("author")
self._sync_author_detail()
_end_managingeditor = _end_author
@@ -160,8 +161,9 @@ def _start_contributor(self, attrs_d):
self.push("contributor", 0)
def _end_contributor(self):
- self.pop("contributor")
+ # Exit contributor context before pop()
self.incontributor = 0
+ self.pop("contributor")
def _start_name(self, attrs_d):
self.push("name", 0)
diff --git a/tests/wellformed/atom10/entry_author_custom_element.xml b/tests/wellformed/atom10/entry_author_custom_element.xml
new file mode 100644
index 00000000..9c5b9a3f
--- /dev/null
+++ b/tests/wellformed/atom10/entry_author_custom_element.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ Example author
+ MIT
+
+
+
diff --git a/tests/wellformed/atom10/entry_author_custom_element_not_in_entry.xml b/tests/wellformed/atom10/entry_author_custom_element_not_in_entry.xml
new file mode 100644
index 00000000..5d97ab14
--- /dev/null
+++ b/tests/wellformed/atom10/entry_author_custom_element_not_in_entry.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ Example author
+ MIT
+
+
+
diff --git a/tests/wellformed/atom10/entry_authors_custom_elements.xml b/tests/wellformed/atom10/entry_authors_custom_elements.xml
new file mode 100644
index 00000000..c4b13203
--- /dev/null
+++ b/tests/wellformed/atom10/entry_authors_custom_elements.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ Alice
+ MIT
+
+
+ Bob
+ Stanford
+
+
+
diff --git a/tests/wellformed/atom10/entry_contributor_custom_element.xml b/tests/wellformed/atom10/entry_contributor_custom_element.xml
new file mode 100644
index 00000000..bd5212c6
--- /dev/null
+++ b/tests/wellformed/atom10/entry_contributor_custom_element.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ Bob Helper
+ editor
+
+
+