aboutsummaryrefslogtreecommitdiff
path: root/src/common/saslprep.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-12-21 09:37:11 +0900
committerMichael Paquier <michael@paquier.xyz>2020-12-21 09:37:11 +0900
commit93e8ff8701a65a70ea8826bdde7fdbbd9c285477 (patch)
tree70afa5868c3b27609fe50097204bba45a21092d6 /src/common/saslprep.c
parent4e1ee79e3182256d9c8ddbc1ce9c4e8419c611ff (diff)
downloadpostgresql-93e8ff8701a65a70ea8826bdde7fdbbd9c285477.tar.gz
postgresql-93e8ff8701a65a70ea8826bdde7fdbbd9c285477.zip
Refactor logic to check for ASCII-only characters in string
The same logic was present for collation commands, SASLprep and pgcrypto, so this removes some code. Author: Michael Paquier Reviewed-by: Stephen Frost, Heikki Linnakangas Discussion: https://postgr.es/m/X9womIn6rne6Gud2@paquier.xyz
Diffstat (limited to 'src/common/saslprep.c')
-rw-r--r--src/common/saslprep.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/common/saslprep.c b/src/common/saslprep.c
index d60452f75f2..48eb1ee9bb9 100644
--- a/src/common/saslprep.c
+++ b/src/common/saslprep.c
@@ -26,6 +26,7 @@
#endif
#include "common/saslprep.h"
+#include "common/string.h"
#include "common/unicode_norm.h"
#include "mb/pg_wchar.h"
@@ -47,7 +48,6 @@
static int codepoint_range_cmp(const void *a, const void *b);
static bool is_code_in_table(pg_wchar code, const pg_wchar *map, int mapsize);
static int pg_utf8_string_len(const char *source);
-static bool pg_is_ascii_string(const char *p);
/*
* Stringprep Mapping Tables.
@@ -1019,21 +1019,6 @@ pg_utf8_string_len(const char *source)
return num_chars;
}
-/*
- * Returns true if the input string is pure ASCII.
- */
-static bool
-pg_is_ascii_string(const char *p)
-{
- while (*p)
- {
- if (IS_HIGHBIT_SET(*p))
- return false;
- p++;
- }
- return true;
-}
-
/*
* pg_saslprep - Normalize a password with SASLprep.
@@ -1076,7 +1061,7 @@ pg_saslprep(const char *input, char **output)
* Quick check if the input is pure ASCII. An ASCII string requires no
* further processing.
*/
- if (pg_is_ascii_string(input))
+ if (pg_is_ascii(input))
{
*output = STRDUP(input);
if (!(*output))