[TD] Fix win file spec backslash (fix #16646) (#16689)

* [TD]add method to clean win filespecs

- '\' in strings passed to Python as filespecs is interpreted as
  an escape of the following character.
- replace '\' with '/'

* [TD]remove '\' from filespecs before use
This commit is contained in:
WandererFan
2024-09-23 11:40:05 -04:00
committed by GitHub
parent b4e29414b6
commit a1ff05f382
8 changed files with 58 additions and 20 deletions

View File

@@ -1899,6 +1899,18 @@ bool DrawUtil::isCenterLine(App::DocumentObject* owner, std::string element)
return false;
}
//! convert a filespec (string) containing '\' to only use '/'.
//! prevents situation where '\' is interpreted as an escape of the next character in Python
//! commands.
std::string DrawUtil::cleanFilespecBackslash(const std::string& filespec)
{
std::string forwardSlash{"/"};
boost::regex rxBackslash("\\\\"); //this rx really means match to a single '\'
std::string noBackslash = boost::regex_replace(filespec, rxBackslash, forwardSlash);
return noBackslash;
}
//============================
// various debugging routines.
void DrawUtil::dumpVertexes(const char* text, const TopoDS_Shape& s)