Skip to content

Commit

Permalink
Move checkTimeFormat check to CRequest class
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrunbauer committed Apr 14, 2024
1 parent 9736ea0 commit b47cc1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 0 additions & 13 deletions adagucserverEC/CDBAdapterPostgreSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,6 @@ CDBStore::Store *CDBAdapterPostgreSQL::getFilesAndIndicesForDimensions(CDataSour
CT::string *sDims = queryParams.splitToArray("/"); // Split up by slashes (and put into sDims)
// It is allowed to pass time as a range: start/end. If we do this, we assume to given value is datetime string

// Verify if time dimension is valid
bool isTime1Valid = CServerParams::checkTimeFormat(sDims[0]);
bool isTime2Valid = true;
if (sDims->count > 1) {
isTime2Valid = CServerParams::checkTimeFormat(sDims[0]);
}
if (!isTime1Valid || !isTime2Valid) {
// FIXME: should we just print the given dimension? Also maybe datetime validation should happen outside this method
if ((CServerParams::checkDataRestriction() & SHOW_QUERYINFO) == false) query.copy("hidden");
CDBError("queryOrderedDESC fails regular expression: '%s'", query.c_str());
return NULL;
}

dimMap[dim->netCDFDimName.c_str()] = sDims;
}

Expand Down
14 changes: 14 additions & 0 deletions adagucserverEC/CRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,20 @@ int CRequest::fillDimValuesForDataSource(CDataSource *dataSource, CServerParams
}
}

// Check if requested time dimensions use valid characters
for (auto &dim: dataSource->requiredDims) {
// FIXME: checkTimeFormat used to get called on every dim value, not just datetime. Check if this is required
if (!dim->isATimeDimension) continue;

CT::string *dimValues = dim->value.splitToArray(",");
for (size_t i = 0; i < dimValues->count; i++) {
if (!CServerParams::checkTimeFormat(dimValues[i])) {
CDBError("Queried dimension %s=%s failed datetime regex", dim->name.c_str(), dim->value.c_str());
throw InvalidDimensionValue;
}
}
}

// STOP NOW
} catch (int i) {
CDBError("%d", i);
Expand Down

0 comments on commit b47cc1c

Please sign in to comment.