fix: sonarqube security hotspot fix

This commit is contained in:
Sebastian Dine
2026-05-09 14:51:55 +02:00
committed by GitHub
parent c434ee51a7
commit 108863b795
2 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# Card Collection Manager 3 # Card Collection Manager 3
[![SonarCloud Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=sebastiandine_Card-Collection-Manager-3&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=sebastiandine_Card-Collection-Manager-3) [![SonarQube Cloud](https://sonarcloud.io/images/project_badges/sonarcloud-dark.svg)](https://sonarcloud.io/summary/new_code?id=sebastiandine_Card-Collection-Manager-3)
Card Collection Manager 3 is an extensible desktop application for managing trading card game collections. It is designed as a practical way to track cards and manage per-card images for large collections, with local per-game data, set synchronization workflows, and a desktop-first UX. The app preserves the established JSON layout from earlier CCM versions so existing collections stay compatible. Card Collection Manager 3 is an extensible desktop application for managing trading card game collections. It is designed as a practical way to track cards and manage per-card images for large collections, with local per-game data, set synchronization workflows, and a desktop-first UX. The app preserves the established JSON layout from earlier CCM versions so existing collections stay compatible.
+5 -4
View File
@@ -4,7 +4,6 @@
#include <wx/image.h> #include <wx/image.h>
#include <algorithm> #include <algorithm>
#include <cstring>
#include <string> #include <string>
#include <string_view> #include <string_view>
@@ -68,12 +67,14 @@ namespace {
// Substitute every "@FILL@" occurrence in `tmpl` with `fill`. // Substitute every "@FILL@" occurrence in `tmpl` with `fill`.
std::string applyFill(const char* tmpl, const char* fill) { std::string applyFill(const char* tmpl, const char* fill) {
std::string s(tmpl); std::string s = tmpl != nullptr ? tmpl : "";
constexpr std::string_view kPlaceholder = "@FILL@"; constexpr std::string_view kPlaceholder = "@FILL@";
const std::string_view fillView = fill != nullptr ? std::string_view(fill)
: std::string_view{};
for (std::string::size_type pos = s.find(kPlaceholder); for (std::string::size_type pos = s.find(kPlaceholder);
pos != std::string::npos; pos != std::string::npos;
pos = s.find(kPlaceholder, pos + std::strlen(fill))) { pos = s.find(kPlaceholder, pos + fillView.size())) {
s.replace(pos, kPlaceholder.size(), fill); s.replace(pos, kPlaceholder.size(), fillView);
} }
return s; return s;
} }