13
0

Do not allow ctrl chars in file (or session) names (1/2)

This commit is contained in:
Robin Gareus 2020-06-09 20:18:02 +02:00
parent e848afe2ec
commit 72d45c154a
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 14 additions and 8 deletions

View File

@ -357,7 +357,8 @@ public:
template<class A> void foreach_route (void (Route::*method)(A), A arg);
template<class A1, class A2> void foreach_route (void (Route::*method)(A1, A2), A1 arg1, A2 arg2);
static char session_name_is_legal (const std::string&);
static const std::string session_name_is_legal (const std::string&);
bool io_name_is_legal (const std::string&) const;
boost::shared_ptr<Route> route_by_name (std::string) const;
boost::shared_ptr<Route> route_by_id (PBD::ID) const;

View File

@ -828,7 +828,7 @@ MidiRegion::set_name (const std::string& str)
return true;
}
if (Session::session_name_is_legal (str) != 0) {
if (!Session::session_name_is_legal (str).empty ()) {
return false;
}

View File

@ -6760,18 +6760,23 @@ Session::update_latency_compensation (bool force_whole_graph, bool called_from_b
DEBUG_TRACE (DEBUG::LatencyCompensation, "update_latency_compensation: complete\n");
}
char
const std::string
Session::session_name_is_legal (const string& path)
{
char illegal_chars[] = { '/', '\\', ':', ';', '\0' };
char illegal_chars[] = { '/', '\\', ':', ';' };
for (int i = 0; illegal_chars[i]; ++i) {
if (path.find (illegal_chars[i]) != string::npos) {
return illegal_chars[i];
return std::string (1, illegal_chars[i]);
}
}
return 0;
for (size_t i = 0; i < path.length(); ++i) {
if (iscntrl (path[i])) {
return _("Control Char");
}
}
return std::string ();
}
void

View File

@ -2933,9 +2933,9 @@ OSC::name_session (char *n, lo_message msg)
return -1;
}
string new_name = n;
char illegal = Session::session_name_is_legal (new_name);
std::string const& illegal = Session::session_name_is_legal (new_name);
if (illegal) {
if (!illegal.empty()) {
PBD::warning << (string_compose (_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"), illegal)) << endmsg;
return -1;