2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[2442] rejected extra \n for std::string version of txt-like ctor.

This commit is contained in:
JINMEI Tatuya
2012-12-04 19:26:40 -08:00
parent 8201bad569
commit ec4fcc7956
2 changed files with 16 additions and 3 deletions

View File

@@ -88,9 +88,14 @@ public:
try {
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) {
isc_throw(InvalidRdataText, "Failed to construct " <<
RRType(typeCode) << " RDATA from " << txtstr << ": "
RRType(typeCode) << " RDATA from '" << txtstr << "': "
<< ex.what());
}
}

View File

@@ -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) {
// If the input text doesn't contain any character-string, it should be
// rejected