From 7c7dc292ff39feb9ce0b9beda782f02e0f868d14 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Mon, 30 Jul 2012 15:46:09 +0200 Subject: PFW: Mapping values are not truncated after ':' BZ: 49228 When an mapping value contains a ':', anything after is no longer ignored. Example : the PFW used to consider the mapping field as: "Directory:/sys/bus/pci/devices/0000" but now it is consided entirely: "Directory:/sys/bus/pci/devices/00 00:00:06.6/" Change-Id: I95711fb4e4ee7d10739e6393717a08627192bb00 Signed-off-by: Kevin Rocard Reviewed-on: http://android.intel.com:8080/59569 Reviewed-by: Becker, VincentX Reviewed-by: Mendi, EduardoX Tested-by: Mendi, EduardoX Reviewed-by: buildbot Tested-by: buildbot --- parameter/MappingData.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'parameter') diff --git a/parameter/MappingData.cpp b/parameter/MappingData.cpp index a577439..4ec58e3 100644 --- a/parameter/MappingData.cpp +++ b/parameter/MappingData.cpp @@ -42,10 +42,26 @@ bool CMappingData::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext while (!(strMappingElement = mappingTok.next()).empty()) { - Tokenizer keyValueTok(strMappingElement, ":"); + string::size_type iFistDelimiterOccurrence = strMappingElement.find_first_of(':'); - string strKey = keyValueTok.next(); - string strValue = keyValueTok.next(); + string strKey, strValue; + + if (iFistDelimiterOccurrence == string::npos) { + + // There is no delimiter in the mapping field, + // it means that no value has been provided + strKey = strMappingElement; + strValue = ""; + + } else { + + // Get mapping key + strKey = strMappingElement.substr(0, iFistDelimiterOccurrence); + + // Get mapping value + strValue = strMappingElement.substr(iFistDelimiterOccurrence + 1); + + } if (!addValue(strKey, strValue)) { -- cgit v1.1