mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
fix: disallow null char at the end of input
since std::string and ""_toml literal actually does not include null char, we don't need to check if the last char is null or not
This commit is contained in:
@@ -87,6 +87,7 @@ operator"" _toml(const char* str, std::size_t len)
|
||||
::toml::detail::location loc(
|
||||
std::string("TOML literal encoded in a C++ code"),
|
||||
std::vector<char>(str, str + len));
|
||||
// literal length does not include the null character at the end.
|
||||
return literal_internal_impl(std::move(loc));
|
||||
}
|
||||
|
||||
|
@@ -2209,13 +2209,6 @@ parse(std::istream& is, const std::string& fname = "unknown file")
|
||||
std::vector<char> letters(static_cast<std::size_t>(fsize));
|
||||
is.read(letters.data(), fsize);
|
||||
|
||||
// remove null character if exists
|
||||
while(!letters.empty() && letters.back() == '\0')
|
||||
{
|
||||
letters.pop_back();
|
||||
}
|
||||
assert(letters.empty() || letters.back() != '\0');
|
||||
|
||||
// append LF.
|
||||
// Although TOML does not require LF at the EOF, to make parsing logic
|
||||
// simpler, we "normalize" the content by adding LF if it does not exist.
|
||||
|
Reference in New Issue
Block a user