mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-02-08 07:54:13 +01:00
Merge pull request #240 from owncloud/parse_url-not-filtervar
use parse_url to verify dn, because filter_var has issues with specia…
This commit is contained in:
commit
5535cbbfb5
@ -96,7 +96,8 @@ class BookmarkController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if it is a valid URL (after adding http(s) prefix)
|
// Check if it is a valid URL (after adding http(s) prefix)
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
|
$urlData = parse_url($url);
|
||||||
|
if ($urlData === false || !isset($urlData['scheme']) || !isset($urlData['host'])) {
|
||||||
return new JSONResponse(array('status' => 'error'), Http::STATUS_BAD_REQUEST);
|
return new JSONResponse(array('status' => 'error'), Http::STATUS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,8 @@ class BookmarkController extends ApiController {
|
|||||||
public function editBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "") {
|
public function editBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "") {
|
||||||
|
|
||||||
// Check if it is a valid URL
|
// Check if it is a valid URL
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
|
$urlData = parse_url($url);
|
||||||
|
if ($urlData === false || !isset($urlData['scheme']) || !isset($urlData['host'])) {
|
||||||
return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
|
return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +192,8 @@ class BookmarkController extends ApiController {
|
|||||||
public function clickBookmark($url = "") {
|
public function clickBookmark($url = "") {
|
||||||
|
|
||||||
// Check if it is a valid URL
|
// Check if it is a valid URL
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
|
$urlData = parse_url($url);
|
||||||
|
if ($urlData === false || !isset($urlData['scheme']) || !isset($urlData['host'])) {
|
||||||
return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
|
return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,10 @@ class Test_LibBookmarks_Bookmarks extends PHPUnit_Framework_TestCase {
|
|||||||
function testAddBookmark() {
|
function testAddBookmark() {
|
||||||
$this->cleanDB();
|
$this->cleanDB();
|
||||||
$this->assertCount(0, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1));
|
$this->assertCount(0, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1));
|
||||||
Bookmarks::addBookmark($this->userid, $this->db, 'http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project');
|
Bookmarks::addBookmark($this->userid, $this->db, 'http://owncloud.org', 'owncloud project', array('oc', 'cloud'), 'An Awesome project');
|
||||||
$this->assertCount(1, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1));
|
$this->assertCount(1, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1));
|
||||||
|
Bookmarks::addBookmark($this->userid, $this->db, 'http://de.wikipedia.org/Ü', 'Das Ü', array('encyclopedia', 'lang'), 'A terrific letter');
|
||||||
|
$this->assertCount(2, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFindBookmarks() {
|
function testFindBookmarks() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user