Skip to content

Commit

Permalink
Fix handling file names with "%" in their names in wxrc
Browse files Browse the repository at this point in the history
In the original code:

```
s.Printf(wxFileNameFromPath(parOutput) + wxT("$%03i-") + name2, i);
```

if `wxFileNameFromPath(parOutput2)` or `name2` had contained `'%'`
(format specifiers), the results would have been bad.

These strings are now given as additional arguments to `Printf`
(corresponding to `"%s"` format specifiers), and the format string
argument itself is now constant.

Closes #24547.
  • Loading branch information
DoctorNoobingstoneIPresume authored and vadz committed May 22, 2024
1 parent e9b0bd5 commit a01c470
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/wxrc/wxrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,14 @@ wxString XmlResApp::GetInternalFileName(const wxString& name, const wxArrayStrin
name2.Replace(wxT("*"), wxT("_"));
name2.Replace(wxT("?"), wxT("_"));

wxString s = wxFileNameFromPath(parOutput) + wxT("$") + name2;
const wxString parOutput_fileName{wxFileNameFromPath(parOutput)};
wxString s{wxString::Format(wxT("%s$%s"), parOutput_fileName, name2)};

if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND)
{
for (int i = 0;; i++)
{
s.Printf(wxFileNameFromPath(parOutput) + wxT("$%03i-") + name2, i);
s.Printf(wxT("%s$%03i-%s"), parOutput_fileName, i, name2);
if (!wxFileExists(s) || flist.Index(s) != wxNOT_FOUND)
break;
}
Expand Down

0 comments on commit a01c470

Please sign in to comment.