mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +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 {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ TYPED_TEST(Rdata_TXT_LIKE_Test, createFromText) {
|
||||
std::stringstream ss;
|
||||
ss << "Test-String\n";
|
||||
ss << "\"Test-String\"\n"; // explicitly surrounded by '"'s
|
||||
ss << "(\n\"Test-String\")\n"; // multi-line text with ()
|
||||
ss << "(\n \"Test-String\" )\n"; // multi-line text with ()
|
||||
ss << "\"\"\n"; // empty string (note: still valid char-str)
|
||||
ss << string(255, 'a') << "\n"; // Longest possible character-string.
|
||||
ss << string(256, 'a') << "\n"; // char-string too long
|
||||
@@ -126,7 +126,7 @@ TYPED_TEST(Rdata_TXT_LIKE_Test, createFromText) {
|
||||
EXPECT_EQ(MasterToken::END_OF_LINE, this->lexer.getNextToken().getType());
|
||||
|
||||
// multi-line input with ()
|
||||
EXPECT_EQ(0, TypeParam("(\n\"Test-String\")").compare(*rdata));
|
||||
EXPECT_EQ(0, TypeParam("(\n \"Test-String\" )").compare(*rdata));
|
||||
EXPECT_EQ(0, TypeParam(this->lexer, NULL, MasterLoader::MANY_ERRORS,
|
||||
this->loader_cb).compare(*rdata));
|
||||
EXPECT_EQ(MasterToken::END_OF_LINE, this->lexer.getNextToken().getType());
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user