Skip to content

Fix two input messages that failed to format - #5574

Merged
bska merged 3 commits into
OPM:masterfrom
GitPaean:brace-safe-input-messages
Nov 18, 2026
Merged

bska merged 3 commits into
OPM:masterfrom
GitPaean:brace-safe-input-messages

Conversation

@GitPaean

@GitPaean GitPaean commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

The NEFAC warning for a standard network used {filename} and {lineno}, but the location formatter only supplies {keyword}, {file} and {line}. Schedule construction therefore stopped instead of warning:

Problem with keyword NEFAC
In CASE.DATA line 16.
argument not found

It now warns NEFAC has no effect for a standard network: file CASE.DATA line 16 and ignores the keyword.

Stray deck text containing braces broke the PARSE_RANDOM_TEXT message the same way. The text goes into a message that is formatted again with the location, so a stray line {x} was read as a placeholder and parsing stopped with a bare argument not found, without a location. The braces are now doubled first:

String {x} not formatted as valid keyword
In CASE.DATA line 1.

The NEFAC warning for a standard network used placeholders unknown to
the location formatter, so schedule construction failed instead of
warning.  Random text containing braces broke the PARSE_RANDOM_TEXT
message the same way.
@GitPaean GitPaean added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Nov 16, 2026
@GitPaean
GitPaean marked this pull request as draft November 16, 2026 14:22
@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this please

@GitPaean
GitPaean marked this pull request as ready for review November 17, 2026 11:45
@GitPaean

Copy link
Copy Markdown
Member Author

This is something spotted by agent during the review of the PR #5442 . I am marking the PR as ready for review now.

@GitPaean
GitPaean requested a review from bska November 17, 2026 11:46

@bska bska left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is mostly okay, but please check if the escape function is sufficiently robust.

Comment on lines +116 to +121
for (const auto c : text) {
escaped += c;
if ((c == '{') || (c == '}')) {
escaped += c;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that a text of the form

alpha b{{et}}a gamma

becomes

alpha b{{{{et}}}}a gamma

Is that intentional

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's intentional. The escaped text isn't the final message: handleError() passes it through OpmInputError::format(), which formats it once more with the keyword location, and that turns each {{ back into { and each }} into }. So alpha b{{et}}a gamma in the deck shows up unchanged in the message. Braces are the only special characters in a format string, so doubling each one works for any text.

A test is added using b{{et}}a gamma.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's intentional. [...]

A test is added using b{{et}}a gamma.

Very good.

@GitPaean

Copy link
Copy Markdown
Member Author

jenkins build this please

@bska bska left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the additional explanation and test. I'll merge into master.

Comment on lines +116 to +121
for (const auto c : text) {
escaped += c;
if ((c == '{') || (c == '}')) {
escaped += c;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's intentional. [...]

A test is added using b{{et}}a gamma.

Very good.

@bska
bska merged commit 3eb4bb3 into OPM:master Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants