Mercurial > hg > orthanc-databases
diff Framework/MySQL/MySQLDatabase.cpp @ 60:412e30336847
allowing dollars and underscores in MySQL database identifiers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 19 Nov 2018 15:06:08 +0100 |
parents | 6a574d810b98 |
children | 714c5d2bee76 |
line wrap: on
line diff
--- a/Framework/MySQL/MySQLDatabase.cpp Sun Oct 28 12:29:22 2018 +0100 +++ b/Framework/MySQL/MySQLDatabase.cpp Mon Nov 19 15:06:08 2018 +0100 @@ -328,7 +328,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } - if (!IsAlphanumericString(name)) + if (!IsValidDatabaseIdentifier(name)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } @@ -360,7 +360,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } - if (!IsAlphanumericString(name)) + if (!IsValidDatabaseIdentifier(name)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } @@ -480,11 +480,14 @@ } - bool MySQLDatabase::IsAlphanumericString(const std::string& s) + bool MySQLDatabase::IsValidDatabaseIdentifier(const std::string& s) { for (size_t i = 0; i < s.length(); i++) { - if (!isalnum(s[i])) + // https://dev.mysql.com/doc/refman/8.0/en/identifiers.html + if (!isalnum(s[i]) && + s[i] != '$' && + s[i] != '_') { return false; }