values['r'] = raw_convert<string> (reel_index + 1);
values['n'] = raw_convert<string> (reel_count);
if (summary) {
- values['c'] = summary.get();
+ values['c'] = careful_string_filter (summary.get());
}
return Config::instance()->dcp_asset_filename_format().get(values, "_" + asset->id() + ".mxf");
}
values['r'] = raw_convert<string> (reel_index + 1);
values['n'] = raw_convert<string> (reel_count);
if (summary) {
- values['c'] = summary.get();
+ values['c'] = careful_string_filter (summary.get());
}
return Config::instance()->dcp_asset_filename_format().get(values, "_" + asset->id() + ".mxf");
}
return lexical_cast<float> (s);
}
}
+
+string
+careful_string_filter (string s)
+{
+ /* Filter out `bad' characters which `may' cause problems with some systems (either for DCP name or filename).
+ There's no apparent list of what really is allowed, so this is a guess.
+ Safety first and all that.
+ */
+
+ string out;
+ string const allowed = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_%.";
+ for (size_t i = 0; i < s.size(); ++i) {
+ if (allowed.find (s[i]) != string::npos) {
+ out += s[i];
+ }
+ }
+
+ return out;
+}