Ticket #91: svn.ticket93.search-on-unknown-string.patch

File svn.ticket93.search-on-unknown-string.patch, 2.0 KB (added by sebastian, 2 years ago)

untouch quicksearch input and escape of output

  • controllers/explorer_controller.php

     
    7676      // Split the query so that we have a list of tags/categories/locations. 
    7777      // For now we split at whitespaces, improvements could be made to not 
    7878      // split multiple tags/categories/locations enclosed in quotation marks 
    79       $quicksearch = preg_split('/\s+/', trim($quicksearch)); 
     79      $words = preg_split('/\s+/', trim($quicksearch)); 
    8080 
    8181      // Reduce results to 6  
    8282      $this->Search->setShow(6); 
    8383 
    8484      // Add tag to the query 
    85       $this->Search->addTags($quicksearch); 
     85      $this->Search->addTags($words); 
    8686      // Set variable dataTags for view 
    8787      $this->Search->setTagOp('OR'); 
    8888      $this->set('dataTags', $this->Search->paginate()); 
     
    9090      $this->Search->delTags(); 
    9191      $this->Search->delTagOp(); 
    9292 
    93       $this->Search->addCategories($quicksearch); 
     93      $this->Search->addCategories($words); 
    9494      $this->Search->setCategoryOp('OR'); 
    9595      $this->set('dataCategories', $this->Search->paginate()); 
    9696      $this->Search->delCategories(); 
    9797      $this->Search->delCategoryOp(); 
    9898 
    99       $this->Search->addLocations($quicksearch); 
     99      $this->Search->addLocations($words); 
    100100      $this->Search->setLocationOp('OR'); 
    101101      $this->set('dataLocations', $this->Search->paginate()); 
    102102      $this->Search->delLocations(); 
  • views/explorer/quicksearch.ctp

     
    1212 
    1313if (count($dataTags) + count($dataCategories) + count($dataLocations) == 0): ?> 
    1414<div class="info"> 
    15 Sorry, nothing was found for <?php echo $quicksearch; ?> 
     15Sorry, nothing was found for <?php echo h($quicksearch); ?> 
    1616</div> 
    1717<?php endif; ?> 
    1818