浏览代码

[FacebookBridge] Return error if username starts with slash

Requesting a username with a leading slash would cause error 500
because the requested URI would contain two slashes in a row.

For example username "/test" would result in:
https://facebook.com//test

References #628
logmanoriginal 6 年之前
父节点
当前提交
df6da837dc
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      bridges/FacebookBridge.php

+ 7 - 0
bridges/FacebookBridge.php

@@ -127,7 +127,14 @@ class FacebookBridge extends BridgeAbstract {
 					'header' => 'Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n"
 				)
 			);
+
 			$context = stream_context_create($http_options);
+
+			// First character cannot be a forward slash
+			if(strpos($this->getInput('u'), "/") === 0) {
+				returnClientError('Remove leading slash "/" from the username!');
+			}
+
 			if(!strpos($this->getInput('u'), "/")) {
 				$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1',
 				false,