summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@gmail.com>2021-04-14 02:44:35 -0400
committerNick Vatamaniuc <nickva@users.noreply.github.com>2021-04-16 17:44:43 -0400
commit45de516f4571e4bdc9e0f7007f31e37d6857cc67 (patch)
treeee1be87f3af69ab6d28ffd96979150dc0667293a
parent5b3983994bf293cd8fb50b7bcc93baa5d3d800dc (diff)
downloadcouchdb-45de516f4571e4bdc9e0f7007f31e37d6857cc67.tar.gz
Clean up database name validation in fabric2_db
`normalize_dbname/1` is not needed as database names do not have the `.couch` suffix, and we don't have shard paths any more. For validation, send the `DbName` to the `fabric2_db_plugin` as both the real DbName and the "normalized" one. This is mostly to avoid changing the plugin interface for now and should be eventually updated (in a separate PR).
-rw-r--r--src/fabric/src/fabric2_db.erl24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index 4e0a9fdfa..aab80a803 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -128,7 +128,6 @@
%% wait_for_compaction/2,
dbname_suffix/1,
- normalize_dbname/1,
validate_dbname/1,
%% make_doc/5,
@@ -1126,27 +1125,19 @@ fold_changes(Db, SinceSeq, UserFun, UserAcc, Options) ->
dbname_suffix(DbName) ->
- filename:basename(normalize_dbname(DbName)).
-
-
-normalize_dbname(DbName) ->
- % Remove in the final cleanup. We don't need to handle shards prefix or
- % remove .couch suffixes anymore. Keep it for now to pass all the existing
- % tests.
- couch_db:normalize_dbname(DbName).
+ filename:basename(DbName).
validate_dbname(DbName) when is_list(DbName) ->
validate_dbname(?l2b(DbName));
validate_dbname(DbName) when is_binary(DbName) ->
- Normalized = normalize_dbname(DbName),
fabric2_db_plugin:validate_dbname(
- DbName, Normalized, fun validate_dbname_int/2).
+ DbName, DbName, fun validate_dbname_int/2).
-validate_dbname_int(DbName, Normalized) when is_binary(DbName) ->
+validate_dbname_int(DbName, DbName) when is_binary(DbName) ->
case validate_dbname_length(DbName) of
- ok -> validate_dbname_pat(DbName, Normalized);
+ ok -> validate_dbname_pat(DbName);
{error, _} = Error -> Error
end.
@@ -1160,13 +1151,12 @@ validate_dbname_length(DbName) ->
end.
-validate_dbname_pat(DbName, Normalized) ->
- DbNoExt = couch_util:drop_dot_couch_ext(DbName),
- case re:run(DbNoExt, ?DBNAME_REGEX, [{capture,none}, dollar_endonly]) of
+validate_dbname_pat(DbName) ->
+ case re:run(DbName, ?DBNAME_REGEX, [{capture,none}, dollar_endonly]) of
match ->
ok;
nomatch ->
- case is_system_db_name(Normalized) of
+ case is_system_db_name(DbName) of
true -> ok;
false -> {error, {illegal_database_name, DbName}}
end