PFW: Mapping values are not truncated after ':'
BZ: 49228
When an mapping value contains a ':', anything after is no longer ignored.
Example :
<Component Name="STATE" Type="SYSFS_FILE" Mapping="Directory:/sys/bus/pci/devices/00
00:00:06.6/"/>
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 <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/59569
Reviewed-by: Becker, VincentX <vincentx.becker@intel.com>
Reviewed-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Tested-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
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 @@
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)) {