Created
September 12, 2014 18:56
-
-
Save c0nstantine/395ed75e6c1527d8a22b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/community/shortcodes/adapters/__init__.py b/community/shortcodes/adapters/__init__.py | |
index a2a25cb..ca1dbe9 100644 | |
--- a/community/shortcodes/adapters/__init__.py | |
+++ b/community/shortcodes/adapters/__init__.py | |
@@ -473,8 +473,28 @@ class IframeAdapter(BaseAdapter): | |
brief_text = 'iframe' | |
html_param_prefix = '' | |
+ def _get_url(self): | |
+ parts = urlparse(self.iden) | |
+ if bool(parts.scheme and parts.netloc): | |
+ return self.iden | |
+ | |
+ match = re.search(r'href=[\'"]?([^\'" >]+)', self.iden) | |
+ if match: | |
+ try: | |
+ parts = urlparse(match.group(1)) | |
+ except IndexError: | |
+ return None | |
+ if bool(parts.scheme and parts.netloc): | |
+ return match.group(1) | |
+ | |
+ return None | |
+ | |
def decode_description(self): | |
+ url = self._get_url() | |
+ if not url: | |
+ raise DecodeError | |
+ | |
return u'<iframe src="{}" {}></iframe>'.format( | |
- self.iden, | |
+ url, | |
self._add_extra_html_params(self.params) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment