| 5377 | } |
| 5378 | |
| 5379 | String String::validate_node_name() const { |
| 5380 | const char32_t *cn = ptr(); |
| 5381 | if (cn == nullptr) { |
| 5382 | return String(); |
| 5383 | } |
| 5384 | bool valid = true; |
| 5385 | uint32_t idx = 0; |
| 5386 | while (cn[idx]) { |
| 5387 | const char32_t *c = invalid_node_name_characters; |
| 5388 | while (*c) { |
| 5389 | if (cn[idx] == *c) { |
| 5390 | valid = false; |
| 5391 | break; |
| 5392 | } |
| 5393 | c++; |
| 5394 | } |
| 5395 | if (!valid) { |
| 5396 | break; |
| 5397 | } |
| 5398 | idx++; |
| 5399 | } |
| 5400 | |
| 5401 | if (valid) { |
| 5402 | return *this; |
| 5403 | } |
| 5404 | |
| 5405 | String validated = *this; |
| 5406 | char32_t *nn = validated.ptrw(); |
| 5407 | while (nn[idx]) { |
| 5408 | const char32_t *c = invalid_node_name_characters; |
| 5409 | while (*c) { |
| 5410 | if (nn[idx] == *c) { |
| 5411 | nn[idx] = '_'; |
| 5412 | break; |
| 5413 | } |
| 5414 | c++; |
| 5415 | } |
| 5416 | idx++; |
| 5417 | } |
| 5418 | |
| 5419 | return validated; |
| 5420 | } |
| 5421 | |
| 5422 | String String::get_basename() const { |
| 5423 | int pos = rfind_char('.'); |
no test coverage detected