Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14632061
D18149.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D18149.diff
View Options
diff --git a/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php b/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php
--- a/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php
+++ b/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php
@@ -2,34 +2,37 @@
final class PhabricatorYoutubeRemarkupRule extends PhutilRemarkupRule {
- private $uri;
-
public function getPriority() {
return 350.0;
}
public function apply($text) {
- $this->uri = new PhutilURI($text);
+ try {
+ $uri = new PhutilURI($text);
+ } catch (Exception $ex) {
+ return $text;
+ }
- if ($this->uri->getDomain() &&
- preg_match('/(^|\.)youtube\.com$/', $this->uri->getDomain()) &&
- idx($this->uri->getQueryParams(), 'v')) {
- return $this->markupYoutubeLink();
+ $domain = $uri->getDomain();
+ if (!preg_match('/(^|\.)youtube\.com\z/', $domain)) {
+ return $text;
}
- return $text;
- }
+ $params = $uri->getQueryParams();
+ $v_param = idx($params, 'v');
+ if (!strlen($v_param)) {
+ return $text;
+ }
- public function markupYoutubeLink() {
- $v = idx($this->uri->getQueryParams(), 'v');
$text_mode = $this->getEngine()->isTextMode();
$mail_mode = $this->getEngine()->isHTMLMailMode();
if ($text_mode || $mail_mode) {
- return $this->getEngine()->storeText('http://youtu.be/'.$v);
+ return $text;
}
- $youtube_src = 'https://www.youtube.com/embed/'.$v;
+ $youtube_src = 'https://www.youtube.com/embed/'.$v_param;
+
$iframe = $this->newTag(
'div',
array(
@@ -45,6 +48,7 @@
'frameborder' => 0,
),
''));
+
return $this->getEngine()->storeText($iframe);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 7:04 PM (20 h, 30 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6985512
Default Alt Text
D18149.diff (1 KB)
Attached To
Mode
D18149: Fix ambiguous URI parsing in Youtube Remarkup rule
Attached
Detach File
Event Timeline
Log In to Comment