6420: Fix slash removal when multiple slashes are pasted in editor r=def- a=Robyt3

When pasting text containing multiple consecutive (back)slashes in the editor save dialog not all slashes where removed. For example with the text `/a//bb/\/ccc////dddd//\//`.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2023-03-14 14:49:31 +00:00 committed by GitHub
commit 862137a11e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4317,8 +4317,13 @@ void CEditor::RenderFileDialog()
{
// remove '/' and '\'
for(int i = 0; m_aFileDialogFileName[i]; ++i)
{
if(m_aFileDialogFileName[i] == '/' || m_aFileDialogFileName[i] == '\\')
{
str_copy(&m_aFileDialogFileName[i], &m_aFileDialogFileName[i + 1], (int)(sizeof(m_aFileDialogFileName)) - i);
--i;
}
}
m_FilesSelectedIndex = -1;
m_aFilesSelectedName[0] = '\0';
// find first valid entry, if it exists