mirror of https://github.com/polybar/polybar.git
fix: Modules did not validate tags used in formats
The 'value' variable that was used for validation, was empty because it was used in a move at the beginning of the function. Fixes #3043
This commit is contained in:
parent
432e19df01
commit
c552df3b66
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `internal/tray`: The module must use the `<tray>` tag (this is the default) ([`#3037`](https://github.com/polybar/polybar/pull/3037))
|
||||
|
||||
## Fixed
|
||||
- Modules did not validate that all tags (e.g. `<label>`) used in a format were valid for that format ([`#3043`](https://github.com/polybar/polybar/issues/3043), [`#3045`](https://github.com/polybar/polybar/pull/3045))
|
||||
- `internal/tray`: Fixed `module-margin` and `separator` being applied to completely empty tray module ([`#3036`](https://github.com/polybar/polybar/issues/3036), [`#3037`](https://github.com/polybar/polybar/pull/3037))
|
||||
|
||||
## [3.7.0] - 2023-11-05
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace modules {
|
|||
};
|
||||
|
||||
auto format = make_unique<module_format>();
|
||||
format->value = move(value);
|
||||
format->value = std::move(value);
|
||||
format->fg = m_conf.get(m_modname, name + "-foreground", formatdef("foreground", format->fg));
|
||||
format->bg = m_conf.get(m_modname, name + "-background", formatdef("background", format->bg));
|
||||
format->ul = m_conf.get(m_modname, name + "-underline", formatdef("underline", format->ul));
|
||||
|
@ -122,18 +122,14 @@ namespace modules {
|
|||
tag_collection.insert(tag_collection.end(), tags.begin(), tags.end());
|
||||
tag_collection.insert(tag_collection.end(), whitelist.begin(), whitelist.end());
|
||||
|
||||
size_t start, end;
|
||||
while ((start = value.find('<')) != string::npos && (end = value.find('>', start)) != string::npos) {
|
||||
if (start > 0) {
|
||||
value.erase(0, start);
|
||||
end -= start;
|
||||
start = 0;
|
||||
}
|
||||
string tag{value.substr(start, end + 1)};
|
||||
size_t start = 0;
|
||||
size_t end = 0;
|
||||
while ((start = format->value.find('<', start)) != string::npos && (end = format->value.find('>', start)) != string::npos) {
|
||||
string tag{format->value.substr(start, end - start + 1)};
|
||||
if (find(tag_collection.begin(), tag_collection.end(), tag) == tag_collection.end()) {
|
||||
throw undefined_format_tag(tag + " is not a valid format tag for \"" + name + "\"");
|
||||
}
|
||||
value.erase(0, tag.size());
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
m_formats.insert(make_pair(move(name), move(format)));
|
||||
|
|
Loading…
Reference in New Issue