File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ public function execute(): void
100100
101101 while ($ row = Db::$ db ->fetch_assoc ($ request )) {
102102 // We can only add it if we can approve in this board!
103- if ($ allowed_boards = [0 ] || \in_array ($ row ['id_board ' ], $ allowed_boards )) {
103+ if ($ allowed_boards === [0 ] || \in_array ($ row ['id_board ' ], $ allowed_boards )) {
104104 $ attachments [] = $ row ['id_attach ' ];
105105
106106 // Also come up with the redirection URL.
Original file line number Diff line number Diff line change @@ -139,6 +139,15 @@ public function checkRequest(): bool
139139 return false ;
140140 }
141141
142+ // Just in case...
143+ if (
144+ filter_var ($ request ->host , FILTER_VALIDATE_IP ) !== false
145+ || $ request ->host === 'localhost '
146+ || $ request ->host === Url::create (Config::$ boardurl )->host
147+ ) {
148+ return false ;
149+ }
150+
142151 // Ensure any non-ASCII characters in the URL are encoded correctly
143152 $ request = \strval ($ request ->toAscii ());
144153
Original file line number Diff line number Diff line change @@ -488,8 +488,16 @@ public function proxied(): self
488488 return $ proxied ;
489489 }
490490
491- // Don't bother with HTTPS URLs, schemeless URLs, or obviously invalid URLs.
492- if (empty ($ proxied ->scheme ) || empty ($ proxied ->host ) || empty ($ proxied ->path ) || $ proxied ->scheme === 'https ' ) {
491+ if (
492+ // Don't bother with HTTPS URLs, schemeless URLs, or obviously invalid URLs.
493+ empty ($ proxied ->scheme )
494+ || $ proxied ->scheme === 'https '
495+ || empty ($ proxied ->host )
496+ || empty ($ proxied ->path )
497+ // Don't proxy localhost or IP addresses.
498+ || $ proxied ->host === 'localhost '
499+ || filter_var ($ proxied ->host , FILTER_VALIDATE_IP ) !== false
500+ ) {
493501 return $ proxied ;
494502 }
495503
You can’t perform that action at this time.
0 commit comments