[link_scan] apply to POST
This commit is contained in:
parent
57675e4f24
commit
2e536e980c
2 changed files with 6 additions and 6 deletions
|
@ -15,10 +15,10 @@ class LinkScan extends Extension
|
||||||
{
|
{
|
||||||
global $config, $page;
|
global $config, $page;
|
||||||
|
|
||||||
if ($event->page_matches("post/list") && isset($_GET['search'])) {
|
if ($event->page_matches("post/list") && isset($_POST['search'])) {
|
||||||
$trigger = $config->get_string("link_scan_trigger", "https?://");
|
$trigger = $config->get_string("link_scan_trigger", "https?://");
|
||||||
if (preg_match("#.*{$trigger}.*#", $_GET['search'])) {
|
if (preg_match("#.*{$trigger}.*#", $_POST['search'])) {
|
||||||
$ids = $this->scan($_GET['search']);
|
$ids = $this->scan($_POST['search']);
|
||||||
$page->set_mode(PageMode::REDIRECT);
|
$page->set_mode(PageMode::REDIRECT);
|
||||||
$page->set_redirect(search_link(["id=".implode(",", $ids)]));
|
$page->set_redirect(search_link(["id=".implode(",", $ids)]));
|
||||||
$event->stop_processing = true;
|
$event->stop_processing = true;
|
||||||
|
|
|
@ -19,7 +19,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
|
||||||
|
|
||||||
But there is no http://example.com/post/view/65432
|
But there is no http://example.com/post/view/65432
|
||||||
";
|
";
|
||||||
$page = $this->get_page("post/list", ["search" => $text]);
|
$page = $this->post_page("post/list", ["search" => $text]);
|
||||||
|
|
||||||
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
||||||
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect);
|
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect);
|
||||||
|
@ -35,7 +35,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
|
||||||
Look at http://example.com/_images/feb01bab5698a11dd87416724c7a89e3/foobar.jpg
|
Look at http://example.com/_images/feb01bab5698a11dd87416724c7a89e3/foobar.jpg
|
||||||
there is an image or search for e106ea2983e1b77f11e00c0c54e53805 but one that
|
there is an image or search for e106ea2983e1b77f11e00c0c54e53805 but one that
|
||||||
doesn't exist is e106ea2983e1b77f11e00c0c54e50000 o.o";
|
doesn't exist is e106ea2983e1b77f11e00c0c54e50000 o.o";
|
||||||
$page = $this->get_page("post/list", ["search" => $text]);
|
$page = $this->post_page("post/list", ["search" => $text]);
|
||||||
|
|
||||||
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
||||||
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect);
|
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect);
|
||||||
|
@ -48,7 +48,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
|
||||||
$this->post_image("tests/favicon.png", "TeStCase");
|
$this->post_image("tests/favicon.png", "TeStCase");
|
||||||
|
|
||||||
$text = "Look at feb01bab5698a11dd87416724c7a89e3/foobar.jpg";
|
$text = "Look at feb01bab5698a11dd87416724c7a89e3/foobar.jpg";
|
||||||
$page = $this->get_page("post/list", ["search" => $text]);
|
$page = $this->post_page("post/list", ["search" => $text]);
|
||||||
|
|
||||||
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
||||||
$this->assertEquals("/test/post/list/at%20feb01bab5698a11dd87416724c7a89e3%2Ffoobar.jpg%20Look/1", $page->redirect);
|
$this->assertEquals("/test/post/list/at%20feb01bab5698a11dd87416724c7a89e3%2Ffoobar.jpg%20Look/1", $page->redirect);
|
||||||
|
|
Reference in a new issue