Move LADSPA Author string sanitation to libardour.
authorRobin Gareus <robin@gareus.org>
Tue, 30 Jan 2018 18:12:01 +0000 (19:12 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 30 Jan 2018 18:52:09 +0000 (19:52 +0100)
(Also allow dot as valid char: e.g. "James T. Kirk" but keep stripping
common suffixes like <e@mail>.

libs/ardour/plugin_manager.cc

index 37721e6a3a8d1611f95511f13961d0f60081c728..cff8cc79240f6c02e93cc634d859b23ddc85b581 100644 (file)
@@ -678,13 +678,30 @@ PluginManager::ladspa_discover (string path)
                PluginInfoPtr info(new LadspaPluginInfo);
                info->name = descriptor->Name;
                info->category = get_ladspa_category(descriptor->UniqueID);
-               info->creator = descriptor->Maker;
                info->path = path;
                info->index = i;
                info->n_inputs = ChanCount();
                info->n_outputs = ChanCount();
                info->type = ARDOUR::LADSPA;
 
+               string::size_type pos = 0;
+               string creator = descriptor->Maker;
+               /* stupid LADSPA creator strings */
+#ifdef PLATFORM_WINDOWS
+               while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]) || creator[pos] == '.')) ++pos;
+#else
+               while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]) || creator[pos] == '.')) ++pos;
+#endif
+
+               /* If there were too few characters to create a
+                * meaningful name, mark this creator as 'Unknown'
+                */
+               if (creator.length() < 2 || pos < 3) {
+                       info->creator = "Unknown";
+               } else{
+                       info->creator = creator.substr (0, pos);
+               }
+
                char buf[32];
                snprintf (buf, sizeof (buf), "%lu", descriptor->UniqueID);
                info->unique_id = buf;