提交 3d6147fd 编写于 作者: G Ganlin Zhao

fix(query): fix to_iso8601 timezone param check

上级 a9787ea4
...@@ -921,11 +921,11 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { ...@@ -921,11 +921,11 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
/* Following are valid iso-8601 timezone format: /* Following are valid ISO-8601 timezone format:
* z/Z * 1 z/Z
* ±hh:mm * 2 ±hh:mm
* ±hhmm * 3 ±hhmm
* ±hh * 4 ±hh
* *
*/ */
...@@ -934,8 +934,8 @@ static bool validateTimezoneFormat(const SValueNode* pVal) { ...@@ -934,8 +934,8 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
return false; return false;
} }
char *tz = pVal->datum.p; char *tz = varDataVal(pVal->datum.p);
int32_t len = (int32_t)strlen(tz); int32_t len = varDataLen(pVal->datum.p);
if (len == 0) { if (len == 0) {
return false; return false;
...@@ -944,16 +944,27 @@ static bool validateTimezoneFormat(const SValueNode* pVal) { ...@@ -944,16 +944,27 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
} else if ((tz[0] == '+' || tz[0] == '-')) { } else if ((tz[0] == '+' || tz[0] == '-')) {
switch (len) { switch (len) {
case 3: case 3:
case 5: case 5: {
for (int32_t i = 1; i < len; ++i) {
if (!isdigit(tz[i])) {
return false;
}
}
break;
}
case 6: { case 6: {
for (int32_t i = 1; i < len; ++i) { for (int32_t i = 1; i < len; ++i) {
if (len == 6 && i == 3 && tz[i] != ':') { if (i == 3) {
if (tz[i] != ':') {
return false; return false;
} }
continue;
}
if (!isdigit(tz[i])) { if (!isdigit(tz[i])) {
return false; return false;
} }
} }
break;
} }
default: { default: {
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册