gazebosim / gazebosim/sdformat
String trimming only considers space and tab
- Dominant language
- C++
- Stars
- 216
- Forks
- 125
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 14
Description
**Original report ([archived issue](https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/issues/194)) by Sean Curtis (Bitbucket: [SeanCurtisTRI](https://bitbucket.org/%7B9c62c800-3df6-43f2-a552-2739fb7f01c4%7D/)).**
----------------------------------------
In the [`sdf::trim`](https://github.com/osrf/sdformat/blob/f20d6093ce5e31f2f1f5cccb1259aa5e02720c78/src/Types.cc#L51) function, it is trimming off leading and trailing space and tab characters. I'd recommend going further in capturing *all* characters that C++ considers to be whitespace. Something like:
```c++
std::string trim(const std::string& name) {
std::regex trim_regex("^\\s*(.*?)\\s*$");
std::smatch matches;
std::regex_match(name, matches, trim_regex);
return matches[1].str();
}
```
Also, we might want to consider what whitespace is allowed *inside* strings. It would be silly to have a name: `"a\f\vb"`.
Contributor guide
Assessment
This issue has not been assessed yet.