Skip to content

Commit

Permalink
feat(src/cli/cli.cc): check if Bundle ID is in reverse DNS notation
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Sep 18, 2023
1 parent 0d42af7 commit 0970597
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ flags | | Advanced Compiler Settings for debug purposes (ie C++ compiler -g, e

Key | Default Value | Description
:--- | :--- | :---
bundle_identifier | | A unique ID that identifies the bundle (used by all app stores). It's required when `[meta] type` is not `"extension"`.
bundle_identifier | | A unique ID that identifies the bundle (used by all app stores). It's required when `[meta] type` is not `"extension"`. It should be in a reverse DNS notation https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier#discussion
copyright | | A string that gets used in the about dialog and package meta info.
description | | A short description of the app.
file_limit | | Set the limit of files that can be opened by your process.
Expand Down
16 changes: 13 additions & 3 deletions src/cli/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2413,9 +2413,19 @@ int main (const int argc, const char* argv[]) {
createSubcommand("build", buildOptions, true, [&](Map optionsWithValue, std::unordered_set<String> optionsWithoutValue) -> void {
auto isForExtensionOnly = settings["meta_type"] == "extension" || settings["build_type"] == "extension";

if (settings["meta_bundle_identifier"].size() == 0 !isForExtensionOnly) {
log("ERROR: [meta] bundle_identifier option is empty");
exit(1);
if (!isForExtensionOnly) {
if (settings["meta_bundle_identifier"].size() == 0) {
log("ERROR: [meta] bundle_identifier option is empty");
exit(1);
}

std::regex reverseDnsPattern(R"(^[a-z0-9]+([-a-z0-9]*[a-z0-9]+)?(\.[a-z0-9]+([-a-z0-9]*[a-z0-9]+)?)*$)", std::regex::icase);
if (!std::regex_match(settings["meta_bundle_identifier"], reverseDnsPattern)) {
log("ERROR: [meta] bundle_name has invalid format :" + settings["meta_bundle_identifier"]);
log("Please use reverse DNS notation (https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier#discussion)");
exit(1);
}

}

String argvForward = "";
Expand Down
4 changes: 3 additions & 1 deletion src/cli/templates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,9 @@ flags = "-g"
[meta]
; A unique ID that identifies the bundle (used by all app stores). It's required when `[meta] type` is not `"extension"`.
; A unique ID that identifies the bundle (used by all app stores).
; It's required when `[meta] type` is not `"extension"`.
; It should be in a reverse DNS notation https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier#discussion
bundle_identifier = "com.beepboop"
; A string that gets used in the about dialog and package meta info.
Expand Down

0 comments on commit 0970597

Please sign in to comment.