diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bcf087..72c601e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ IMPORTANT NOTE: This version only works on CACTI 1.x++! * feature#298: Fit or stretch background images within the map canvas +* feature#297: Allow setting a map title when creating configuration files + * feature#295: Use a readable landscape preset for new blank maps * feature#294: Expose bundled fonts and link comment colours in Map Style diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index 9a61683..7bf44e0 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -1114,7 +1114,7 @@ msgstr "" msgid "Map Properties" msgstr "" -#: weathermap-cacti-plugin-editor.php +#: weathermap-cacti-plugin-editor.php weathermap-cacti-plugin-mgmt.php msgid "Map Title" msgstr "" @@ -1621,6 +1621,10 @@ msgstr "" msgid "Name including .conf" msgstr "" +#: weathermap-cacti-plugin-mgmt.php +msgid "Optional map title" +msgstr "" + #: weathermap-cacti-plugin-mgmt.php msgid "Source Map" msgstr "" @@ -2120,3 +2124,7 @@ msgstr "" #: weathermap-cacti-plugin.php msgid "Paused" msgstr "" + +#: weathermap-cacti-plugin-mgmt.php +msgid "Map title is too long. Use at most 4088 bytes after escaping." +msgstr "" diff --git a/tests/Support/NewMapTitleEngineRegression.php b/tests/Support/NewMapTitleEngineRegression.php new file mode 100644 index 0000000..636f6d7 --- /dev/null +++ b/tests/Support/NewMapTitleEngineRegression.php @@ -0,0 +1,116 @@ + & 'title'\nTITLE injected"); + $saved = new WeatherMap(); + $saved->ReadConfig($directory . '/new.conf'); + wm_engine_assert($saved->title === 'My <network> & 'title' TITLE injected','title round trip and line-break normalization'); + $map = new WeatherMap(); + $map->width = 910; + $map->title = 'Source title'; + $map->WriteConfig($directory . '/source.conf'); + $before = file_get_contents($directory . '/source.conf'); + newMap('copy.conf','source.conf',''); + $copy = new WeatherMap(); + $copy->ReadConfig($directory . '/copy.conf'); + wm_engine_assert($copy->title === 'Source title' && $copy->width == 910,'blank title retains source'); + foreach (["\x01", "\x7f", " \r\n\x02 ", null, []] as $index => $empty_title) { + $filename = 'empty-' . $index . '.conf'; + newMap($filename, 'source.conf', $empty_title); + $empty_copy = new WeatherMap(); + $empty_copy->ReadConfig($directory . '/' . $filename); + wm_engine_assert($empty_copy->title === 'Source title' && $empty_copy->width == 910, 'normalized empty override preserves source title and layout'); + } + newMap('blank-control.conf', '', "\x01"); + $blank = new WeatherMap(); + $blank->ReadConfig($directory . '/blank-control.conf'); + $defaults = new WeatherMap(); + wm_engine_assert($blank->title === $defaults->title, 'normalized empty title preserves a new map default'); + newMap('mixed.conf', 'source.conf', " \x01New\x7ftitle "); + $mixed = new WeatherMap(); + $mixed->ReadConfig($directory . '/mixed.conf'); + wm_engine_assert($mixed->title === 'New title', 'mixed control characters normalize before applying a real override'); + newMap('renamed.conf','source.conf','New