Skip to content
Snippets Groups Projects
Commit 40ff2acd authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: word input is too strict (fixes #2160)

- for v2106 restricted the input conversion of string types to disallow
  treating verbatim strings as possible word input.
  However, it was too strict in just allowing quoted strings
  and should have also permitted '$'-sigil variables as well.

- ensure that errors for bad string -> word input conversion
  are raised from within the '>>' read operator. These were
  previously triggered during the stripping process, which
  made error tracing more difficult.
parent 90ad6ce9
No related branches found
No related tags found
No related merge requests found
......@@ -48,15 +48,16 @@ Foam::Istream& Foam::operator>>(Istream& is, word& val)
{
val = tok.wordToken();
}
else if (tok.isQuotedString())
else if (tok.isQuotedString() || tok.isVariable())
{
// Try a bit harder and convert string to word
val = tok.stringToken();
const auto oldLen = val.length();
string::stripInvalid<word>(val);
// Try a bit harder, convert some string types to word
// - accept "quoted" or $tag, but not verbatim/expression
const auto& str = tok.stringToken();
val = word::validate(str);
// Flag empty strings and bad chars as an error
if (val.empty() || val.length() != oldLen)
if (val.empty() || val.length() != str.length())
{
FatalIOErrorInFunction(is)
<< "Empty word or non-word characters "
......
  • Dear Mark,

    Would you be able to post a fix to this problem in v1706?

  • Author Maintainer

    @thomaschg wow - 1706 is quite old. Not really in maintenance anymore at all. Is this actually even a bug in older versions? Or maybe just not as generous as we now expect?

    Edited by Mark OLESEN
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment