Skip to content

Commit

Permalink
microformats2: don't crash on raw string values for quotation-of
Browse files Browse the repository at this point in the history
for snarfed/bridgy#723

thanks for reporting @gRegorLove! this doesn't (yet) fix the whole bug, but it at least prevents the `'unicode' ... has no attribute 'get'` crash.
  • Loading branch information
snarfed committed Jan 31, 2017
1 parent 5a99426 commit 80d2a10
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion granary/microformats2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"objectType": "note",
"content": "i hereby quote",
"attachments": [{
"objectType": "note",
"content": "this is being quoted",
"url": "http://quoted/post"
}]
}
16 changes: 16 additions & 0 deletions granary/test/testdata/note_with_string_quotation.mf2.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
]
}
}

0 comments on commit 80d2a10

Please sign in to comment.