Fix issue with dashes in fru names
Replace dashes and spaces with underscores.
Change-Id: I94f66f576e1443de46e6c2eb5ca73f52bd79169b
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index f0de41c..e247db7 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -301,7 +301,7 @@
return false;
}
std::string commandStr = *(match.begin() + 1);
- commandStr = boost::replace_all_copy(commandStr, "'", "");
+ boost::replace_all(commandStr, "'", "");
cur = (std::find(PASSED_PROBES.begin(), PASSED_PROBES.end(),
commandStr) != PASSED_PROBES.end());
break;
@@ -318,8 +318,8 @@
}
std::string commandStr = *(match.begin() + 1);
// convert single ticks and single slashes into legal json
- commandStr = boost::replace_all_copy(commandStr, "'", R"(")");
- commandStr = boost::replace_all_copy(commandStr, R"(\)", R"(\\)");
+ boost::replace_all(commandStr, "'", R"(")");
+ boost::replace_all(commandStr, R"(\)", R"(\\)");
auto json = nlohmann::json::parse(commandStr, nullptr, false);
if (json.is_discarded())
{
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index 1c01f95..7272327 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -27,6 +27,7 @@
#include <linux/i2c-dev-user.h>
#include <iostream>
#include <sys/ioctl.h>
+#include <regex>
namespace fs = std::experimental::filesystem;
static constexpr bool DEBUG = false;
@@ -351,6 +352,8 @@
if (productNameFind != formattedFru.end())
{
productName = productNameFind->second;
+ std::regex illegalObject("[^A-Za-z0-9_]");
+ productName = std::regex_replace(productName, illegalObject, "_");
}
else
{