Commit 6eb40147 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[2545] Trim strings representing option field value.

parent bdb56ee0
......@@ -340,9 +340,8 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) {
" \"option-data\": [ {"
" \"name\": \"OPTION_DNS_SERVERS\","
" \"code\": 23,"
" \"data\": \"2001 0DB8 1234 FFFF 0000 0000 0000 0001"
"2001 0DB8 1234 FFFF 0000 0000 0000 0002\","
" \"csv-format\": False"
" \"data\": \"2001:db8:1234:FFFF::1, 2001:db8:1234:FFFF::2\","
" \"csv-format\": True"
" },"
" {"
" \"name\": \"OPTION_FOO\","
......
......@@ -22,6 +22,7 @@
#include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
#include <util/encode/hex.h>
#include <util/strutil.h>
using namespace std;
using namespace isc::util;
......@@ -176,10 +177,10 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
if (values.empty()) {
isc_throw(InvalidOptionValue, "no option value specified");
}
writeToBuffer(values[0], type_, buf);
writeToBuffer(util::str::trim(values[0]), type_, buf);
} else if (array_type_ && type_ != OPT_RECORD_TYPE) {
for (size_t i = 0; i < values.size(); ++i) {
writeToBuffer(values[i], type_, buf);
writeToBuffer(util::str::trim(values[i]), type_, buf);
}
} else if (type_ == OPT_RECORD_TYPE) {
const RecordFieldsCollection& records = getRecordFields();
......@@ -189,7 +190,8 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
<< " provided.");
}
for (size_t i = 0; i < records.size(); ++i) {
writeToBuffer(values[i], records[i], buf);
writeToBuffer(util::str::trim(values[i]),
records[i], buf);
}
}
return (optionFactory(u, type, buf.begin(), buf.end()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment