Explorar o código

[VkBridge] use 'Group or user name' parameter instead of full URI

This breaks compatibility with previous versions of VkBridge (which
seems broken anyway).
Bridges should never use full URIs as inputs since their validation will
always be more complicated, hence prone to security issues,
than rebuilding a clean URI from simple validated inputs.
Pierre Mazière %!s(int64=7) %!d(string=hai) anos
pai
achega
3daeacc208
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      bridges/VkBridge.php

+ 8 - 5
bridges/VkBridge.php

@@ -6,18 +6,21 @@ class VkBridge extends BridgeAbstract {
     const NAME = "VK.com";
     const URI = "http://vk.com/";
     const DESCRIPTION = "Working with open pages";
-    const PARAMETERS=array(
-        'Url on page group or user' => array(
+    const PARAMETERS=array( array(
             'u'=>array(
-                'name'=>'Url',
+                'name'=>'Group or user name',
                 'required'=>true
             )
         )
     );
 
+    public function getURI(){
+      return static::URI.urlencode($this->getInput('u'));
+    }
     public function collectData(){
-        $text_html = $this->getContents(urldecode($this->getInput('u')))
-            or $this->returnServerError('No results for this query.');
+        $text_html = $this->getContents($this->getURI())
+          or $this->returnServerError('No results for group or user name "'.$this->getInput('u').'".');
+
         $text_html = iconv('windows-1251', 'utf-8', $text_html);
         $html = str_get_html($text_html);
         foreach ($html->find('div.post_table') as $post) {