You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/12/03 20:56:31 UTC
[allura] branch db/embed_error_handling created (now d42a93a)
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a change to branch db/embed_error_handling
in repository https://gitbox.apache.org/repos/asf/allura.git.
at d42a93a Handle [[embed]] errors specifically, instead of whole markdown text erroring
This branch includes the following new commits:
new d42a93a Handle [[embed]] errors specifically, instead of whole markdown text erroring
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[allura] 01/01: Handle [[embed]] errors specifically,
instead of whole markdown text erroring
Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/embed_error_handling
in repository https://gitbox.apache.org/repos/asf/allura.git
commit d42a93a1f9c2d8e35e9efe74dd1fae2d47078653
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu Dec 3 15:52:29 2020 -0500
Handle [[embed]] errors specifically, instead of whole markdown text erroring
---
Allura/allura/lib/macro.py | 3 +++
Allura/allura/tests/test_globals.py | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index a7197de..3e58278 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -466,6 +466,9 @@ def embed(url=None):
html = consumer.embed(url)['html']
except oembed.OEmbedNoEndpoint:
html = None
+ except oembed.OEmbedError:
+ log.exception('Could not embed: {}'.format(url))
+ return 'Could not embed: {}'.format(url)
except six.moves.urllib.error.HTTPError as e:
if e.code == 404:
return 'Video not available'
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 7d624ce..a811247 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -25,13 +25,13 @@ import os
import allura
import unittest
import hashlib
-import datetime as dt
from mock import patch, Mock
from bson import ObjectId
from nose.tools import with_setup, assert_equal, assert_in, assert_not_in
from tg import tmpl_context as c, app_globals as g
import tg
+from oembed import OEmbedError
from ming.orm import ThreadLocalORMSession
from alluratest.controller import (
@@ -353,6 +353,14 @@ def test_macro_embed_video_gone():
assert_equal(r, '<div class="markdown_content"><p>Video not available</p></div>')
+@patch('oembed.OEmbedEndpoint.fetch')
+def test_macro_embed_video_error(oembed_fetch):
+ oembed_fetch.side_effect = OEmbedError('Invalid mime-type in response...')
+ r = g.markdown_wiki.convert('[[embed url=http://www.youtube.com/watch?v=6YbBmqUnoQM]]')
+ assert_equal(r, '<div class="markdown_content"><p>Could not embed: '
+ 'http://www.youtube.com/watch?v=6YbBmqUnoQM</p></div>')
+
+
def test_macro_embed_notsupported():
r = g.markdown_wiki.convert('[[embed url=http://vimeo.com/46163090]]')
assert_equal(