diff --git a/granary/microformats2.py b/granary/microformats2.py index bb8cd3bf..97a54fec 100644 --- a/granary/microformats2.py +++ b/granary/microformats2.py @@ -283,7 +283,7 @@ def absolute_urls(prop): attachments = [ json_to_object(quote) for quote in mf2.get('children', []) + props.get('quotation-of', []) - if 'h-cite' in set(quote.get('type', []))] + if isinstance(quote, dict) and 'h-cite' in set(quote.get('type', []))] obj = { 'id': prop.get('uid'), diff --git a/granary/test/testdata/note_with_string_quotation.as-from-mf2.json b/granary/test/testdata/note_with_string_quotation.as-from-mf2.json new file mode 100644 index 00000000..c4ff6b13 --- /dev/null +++ b/granary/test/testdata/note_with_string_quotation.as-from-mf2.json @@ -0,0 +1,9 @@ +{ + "objectType": "note", + "content": "i hereby quote", + "attachments": [{ + "objectType": "note", + "content": "this is being quoted", + "url": "http://quoted/post" + }] +} diff --git a/granary/test/testdata/note_with_string_quotation.mf2.json b/granary/test/testdata/note_with_string_quotation.mf2.json new file mode 100644 index 00000000..77f1fba5 --- /dev/null +++ b/granary/test/testdata/note_with_string_quotation.mf2.json @@ -0,0 +1,16 @@ +{ + "type": ["h-entry"], + "properties": { + "content": ["i hereby quote"], + "quotation-of": [ + "this should be ignored", + { + "type": ["h-cite"], + "properties": { + "content": ["this is being quoted"], + "url": ["http://quoted/post"] + } + } + ] + } +}