From 0fa23475526e118c2401fd29e231ed6286dc3172 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Sun, 25 Feb 2024 22:46:39 -0500 Subject: [PATCH 1/2] Fix url shortener regex --- inc/instance-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/instance-config.php b/inc/instance-config.php index afd8ae0b..b18e24b0 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -564,7 +564,7 @@ $config['filters'][] = array( $config['filters'][] = array( 'condition' => array( - 'body' => '/(^|\s)((https?):\/\/)?[\w-]{2,6}\.[a-z]{2,4}\/\w{2,8}/i', // url shorteners are not allowed + 'body' => '/(^|\s)((https?):\/\/)?[\w-]{2,6}\.[a-z]{2,4}\/\w{2,8}(\s|$)/i', // url shorteners are not allowed ), 'action' => 'reject', 'message' => 'Url shorteners are not allowed' From c3c6c8f9f19e5f4bb88e07af06b0213e7359155f Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Mon, 26 Feb 2024 11:37:38 -0500 Subject: [PATCH 2/2] POST - return new post in json - handle post now returns the new post you just created in the response (if json_response is set, which it is when submitting the form with ajax) --- inc/api.php | 3 ++- inc/display.php | 4 ++++ post.php | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/api.php b/inc/api.php index c097f82c..0a4dca76 100644 --- a/inc/api.php +++ b/inc/api.php @@ -130,8 +130,9 @@ class Api { } } - private function translatePost($post, $threadsPage = false) { + function translatePost($post, $threadsPage = false) { global $config, $board; + $apiPost = array(); $fields = $threadsPage ? $this->threadsPageFields : $this->postFields; $this->translateFields($fields, $post, $apiPost); diff --git a/inc/display.php b/inc/display.php index 06971bc9..76468bea 100644 --- a/inc/display.php +++ b/inc/display.php @@ -380,6 +380,10 @@ class PostProps { class Post extends PostProps { + private $op; + private $raw_body; + private $has_file; + private $tracked_cites; public function __construct($post, $root=null, $mod=false) { global $config; diff --git a/post.php b/post.php index 95ddf512..43dd359a 100644 --- a/post.php +++ b/post.php @@ -458,7 +458,6 @@ function handle_post(){ global $config,$dropped_post,$board, $mod,$pdo; if (!isset($_POST['body'], $_POST['board']) && !$dropped_post) { - print_err('handle_post bot error 1'); error($config['error']['bot']); } @@ -1488,10 +1487,12 @@ function handle_post(){ header('Location: ' . $redirect, true, $config['redirect_http']); } else { header('Content-Type: text/json; charset=utf-8'); + $api = new Api(); echo json_encode(array( 'redirect' => $redirect, 'noko' => $noko, - 'id' => $id + 'id' => $id, + 'post' => $api->translatePost(new Post($post)) )); }