mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-04 07:55:18 +00:00
[2442] rejected extra \n for std::string version of txt-like ctor.
This commit is contained in:
@@ -88,9 +88,14 @@ public:
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
buildFromTextHelper(lexer);
|
buildFromTextHelper(lexer);
|
||||||
|
if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
|
||||||
|
isc_throw(InvalidRdataText, "Failed to construct " <<
|
||||||
|
RRType(typeCode) << " RDATA from '" << txtstr <<
|
||||||
|
"': extra new line");
|
||||||
|
}
|
||||||
} catch (const MasterLexer::LexerError& ex) {
|
} catch (const MasterLexer::LexerError& ex) {
|
||||||
isc_throw(InvalidRdataText, "Failed to construct " <<
|
isc_throw(InvalidRdataText, "Failed to construct " <<
|
||||||
RRType(typeCode) << " RDATA from " << txtstr << ": "
|
RRType(typeCode) << " RDATA from '" << txtstr << "': "
|
||||||
<< ex.what());
|
<< ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -214,6 +214,14 @@ TYPED_TEST(Rdata_TXT_LIKE_Test, createMultiStringsFromText) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(Rdata_TXT_LIKE_Test, createFromTextExtra) {
|
||||||
|
// This is for the std::string version only: the input must end with EOF;
|
||||||
|
// an extra new-line will result in an exception.
|
||||||
|
EXPECT_THROW(TypeParam("\"Test-String\"\n"), InvalidRdataText);
|
||||||
|
// Same if there's a space before '\n'
|
||||||
|
EXPECT_THROW(TypeParam("\"Test-String\" \n"), InvalidRdataText);
|
||||||
|
}
|
||||||
|
|
||||||
TYPED_TEST(Rdata_TXT_LIKE_Test, fromTextEmpty) {
|
TYPED_TEST(Rdata_TXT_LIKE_Test, fromTextEmpty) {
|
||||||
// If the input text doesn't contain any character-string, it should be
|
// If the input text doesn't contain any character-string, it should be
|
||||||
// rejected
|
// rejected
|
||||||
|
Reference in New Issue
Block a user