jaydoane commented on a change in pull request #1647: Validate database prefix
against DBNAME_REGEX for system dbs
URL: https://github.com/apache/couchdb/pull/1647#discussion_r223875659
##########
File path: src/couch/src/couch_db.erl
##########
@@ -1738,8 +1738,16 @@ validate_dbname_int(DbName, Normalized) when
is_binary(DbName) ->
is_systemdb(DbName) when is_list(DbName) ->
is_systemdb(?l2b(DbName));
is_systemdb(DbName) when is_binary(DbName) ->
- lists:member(dbname_suffix(DbName), ?SYSTEM_DATABASES).
-
+ Normalized = normalize_dbname(DbName),
+ Suffix = filename:basename(Normalized),
+ case {filename:dirname(Normalized), lists:member(Suffix,
?SYSTEM_DATABASES)} of
+ {<<".">>, Result} -> Result;
+ {Prefix, false} -> false;
+ {Prefix, true} ->
+ re:run(Prefix, ?DBNAME_REGEX, [{capture,none}, dollar_endonly])
+ ==
+ match
Review comment:
Not sure why `== match` are not on the same line, but I guess it's not a big
deal.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services