Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/YOURLS/YOURLS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author྅༻ Ǭɀħ ༄༆ཉ <ozh@ozh.org>2022-05-29 15:48:08 +0300
committerGitHub <noreply@github.com>2022-05-29 15:48:08 +0300
commit19eb4d5d362d38f194116c381bd224fa6bad727e (patch)
treec6c9231bdc3fdae797a67d281421070c849c8706
parente79b33c706eb48baaf88422c8ae859861e055c0d (diff)
Return 400 instead of 500 when duplicate (#3355)
Fixes #3319
-rw-r--r--includes/functions-shorturls.php1
-rw-r--r--includes/functions.php2
2 files changed, 2 insertions, 1 deletions
diff --git a/includes/functions-shorturls.php b/includes/functions-shorturls.php
index 0036b10d..93dffb74 100644
--- a/includes/functions-shorturls.php
+++ b/includes/functions-shorturls.php
@@ -84,6 +84,7 @@ function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
yourls_trim_long_string($url), preg_replace('!https?://!', '', yourls_get_yourls_site()) . '/'. $url_exists->keyword );
$return['title'] = $url_exists->title;
$return['shorturl'] = yourls_link($url_exists->keyword);
+ $return['errorCode'] = $return['statusCode'] = '400'; // 400 Bad Request
return yourls_apply_filter( 'add_new_link_already_stored_filter', $return, $url, $keyword, $title );
}
diff --git a/includes/functions.php b/includes/functions.php
index 778d3b63..2f6725cf 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -461,7 +461,7 @@ function yourls_get_HTTP_status( $code ) {
510 => 'Not Extended'
];
- return isset( $headers_desc[ $code ] ) ? $headers_desc[ $code ] : '';
+ return $headers_desc[$code] ?? '';
}
/**