drogonframework / drogonframework/drogon

Wrong string size in models

Open
#2,371 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

I have postgreSQL table with string type column. String has 127 symbols limit, so created by drogon_ctl model.cc has check
``` cpp
if(pJson.isString() && std::strlen(pJson.asCString()) > 127)
{
err="String length exceeds limit for the " +
fieldName +
" field (the maximum value is 127)";
return false;
}
```
However, `std::strlen` counts non English letters twice, so this check in `validateJsonForCreation` fails on valid string with more then 63 non English letters.

Maybe this check should use `size()` method of `std::string`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.