Changeset 62919 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 3, 2016 2:16:14 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 109521
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r62468 r62919 1406 1406 void sanitiseMachineFilename(Utf8Str &strName) 1407 1407 { 1408 /* *Set of characters which should be safe for use in filenames: some basic1408 /* Set of characters which should be safe for use in filenames: some basic 1409 1409 * ASCII, Unicode from Latin-1 alphabetic to the end of Hangul. We try to 1410 1410 * skip anything that could count as a control character in Windows or 1411 1411 * *nix, or be otherwise difficult for shells to handle (I would have 1412 1412 * preferred to remove the space and brackets too). We also remove all 1413 * characters which need UTF-16 surrogate pairs for Windows's benefit. */ 1414 RTUNICP aCpSet[] = 1415 { ' ', ' ', '(', ')', '-', '.', '0', '9', 'A', 'Z', 'a', 'z', '_', '_', 1416 0xa0, 0xd7af, '\0' }; 1413 * characters which need UTF-16 surrogate pairs for Windows's benefit. 1414 */ 1415 static RTUNICP const s_uszValidRangePairs[] = 1416 { 1417 ' ', ' ', 1418 '(', ')', 1419 '-', '.', 1420 '0', '9', 1421 'A', 'Z', 1422 'a', 'z', 1423 '_', '_', 1424 0xa0, 0xd7af, 1425 '\0' 1426 }; 1427 1417 1428 char *pszName = strName.mutableRaw(); 1418 ssize_t cReplacements = RTStrPurgeComplementSet(pszName, aCpSet, '_');1429 ssize_t cReplacements = RTStrPurgeComplementSet(pszName, s_uszValidRangePairs, '_'); 1419 1430 Assert(cReplacements >= 0); 1420 1431 NOREF(cReplacements); 1432 1421 1433 /* No leading dot or dash. */ 1422 1434 if (pszName[0] == '.' || pszName[0] == '-') 1423 1435 pszName[0] = '_'; 1436 1424 1437 /* No trailing dot. */ 1425 1438 if (pszName[strName.length() - 1] == '.') 1426 1439 pszName[strName.length() - 1] = '_'; 1440 1427 1441 /* Mangle leading and trailing spaces. */ 1428 1442 for (size_t i = 0; pszName[i] == ' '; ++i)
Note:
See TracChangeset
for help on using the changeset viewer.