| 530 | } |
| 531 | |
| 532 | bool EditorExportPlatformAndroid::is_package_name_valid(const Ref<EditorExportPreset> &p_preset, const String &p_package, String *r_error) const { |
| 533 | String pname = get_package_name(p_preset, p_package); |
| 534 | |
| 535 | if (pname.length() == 0) { |
| 536 | if (r_error) { |
| 537 | *r_error = TTR("Package name is missing."); |
| 538 | } |
| 539 | return false; |
| 540 | } |
| 541 | |
| 542 | int segments = 0; |
| 543 | bool first = true; |
| 544 | for (int i = 0; i < pname.length(); i++) { |
| 545 | char32_t c = pname[i]; |
| 546 | if (first && c == '.') { |
| 547 | if (r_error) { |
| 548 | *r_error = TTR("Package segments must be of non-zero length."); |
| 549 | } |
| 550 | return false; |
| 551 | } |
| 552 | if (c == '.') { |
| 553 | segments++; |
| 554 | first = true; |
| 555 | continue; |
| 556 | } |
| 557 | if (!is_ascii_identifier_char(c)) { |
| 558 | if (r_error) { |
| 559 | *r_error = vformat(TTR("The character '%s' is not allowed in Android application package names."), String::chr(c)); |
| 560 | } |
| 561 | return false; |
| 562 | } |
| 563 | if (first && is_digit(c)) { |
| 564 | if (r_error) { |
| 565 | *r_error = TTR("A digit cannot be the first character in a package segment."); |
| 566 | } |
| 567 | return false; |
| 568 | } |
| 569 | if (first && is_underscore(c)) { |
| 570 | if (r_error) { |
| 571 | *r_error = vformat(TTR("The character '%s' cannot be the first character in a package segment."), String::chr(c)); |
| 572 | } |
| 573 | return false; |
| 574 | } |
| 575 | first = false; |
| 576 | } |
| 577 | |
| 578 | if (segments == 0) { |
| 579 | if (r_error) { |
| 580 | *r_error = TTR("The package must have at least one '.' separator."); |
| 581 | } |
| 582 | return false; |
| 583 | } |
| 584 | |
| 585 | if (first) { |
| 586 | if (r_error) { |
| 587 | *r_error = TTR("Package segments must be of non-zero length."); |
| 588 | } |
| 589 | return false; |
nothing calls this directly
no test coverage detected