{"action":"created","comment":{"url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments/33793026","id":33793026,"diff_hunk":"@@ -848,34 +846,50 @@ sub create_ia :Chained('base') :PathPart('create') :Args() {\n         if ($is_admin) {\n             my $dev_milestone = $c->req->params->{dev_milestone};\n             my $status = $dev_milestone;\n-            \n-            if ($dev_milestone eq 'development') {\n-                $status =~ s/_/ /g;\n-            }\n \n-            my $new_ia = $c->d->rs('InstantAnswer')->create({\n-                id => lc($c->req->params->{id}),\n-                meta_id => lc($c->req->params->{id}),\n-                name => $c->req->params->{name},\n-                status => $status,\n-                dev_milestone => $dev_milestone,\n-                description => $c->req->params->{description},\n-            });\n+            $id = format_id($c->req->params->{id});\n+           \n+            if (length $id) { \n+                my $new_ia = $c->d->rs('InstantAnswer')->create({\n+                    id => $id,\n+                    meta_id => $id,\n+                    name => $c->req->params->{name},\n+                    status => $status,\n+                    dev_milestone => $dev_milestone,\n+                    description => $c->req->params->{description},\n+                });\n \n-            save_milestone_date($new_ia, 'created');\n+                save_milestone_date($new_ia, 'created');\n \n-            $result = 1;\n+                $result = 1;\n+            }\n         }\n     }\n \n     $c->stash->{x} = {\n         result => $result,\n+        id => $id\n     };\n \n     $c->stash->{not_last_url} = 1;\n     return $c->forward($c->view('JSON'));\n }\n \n+sub format_id {\n+    my( $id ) = @_;\n+\n+    # id must be unique, lowercase and without weird chars","path":"lib/DDGC/Web/Controller/InstantAnswer.pm","position":70,"original_position":70,"commit_id":"f66028ea58c5dc983f52553f9f86a48adb8dd8a2","original_commit_id":"f66028ea58c5dc983f52553f9f86a48adb8dd8a2","user":{"login":"MariagraziaAlastra","id":3652195,"avatar_url":"https://avatars.githubusercontent.com/u/3652195?v=3","gravatar_id":"","url":"https://api.github.com/users/MariagraziaAlastra","html_url":"https://github.com/MariagraziaAlastra","followers_url":"https://api.github.com/users/MariagraziaAlastra/followers","following_url":"https://api.github.com/users/MariagraziaAlastra/following{/other_user}","gists_url":"https://api.github.com/users/MariagraziaAlastra/gists{/gist_id}","starred_url":"https://api.github.com/users/MariagraziaAlastra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MariagraziaAlastra/subscriptions","organizations_url":"https://api.github.com/users/MariagraziaAlastra/orgs","repos_url":"https://api.github.com/users/MariagraziaAlastra/repos","events_url":"https://api.github.com/users/MariagraziaAlastra/events{/privacy}","received_events_url":"https://api.github.com/users/MariagraziaAlastra/received_events","type":"User","site_admin":false},"body":"Oh haha that's checked in the caller function, I cut and pasted the comment from there, sorry :)","created_at":"2015-07-02T15:59:22Z","updated_at":"2015-07-02T15:59:22Z","html_url":"https://github.com/duckduckgo/community-platform/pull/809#discussion_r33793026","pull_request_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809","_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments/33793026"},"html":{"href":"https://github.com/duckduckgo/community-platform/pull/809#discussion_r33793026"},"pull_request":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809"}}},"pull_request":{"url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809","id":39093389,"html_url":"https://github.com/duckduckgo/community-platform/pull/809","diff_url":"https://github.com/duckduckgo/community-platform/pull/809.diff","patch_url":"https://github.com/duckduckgo/community-platform/pull/809.patch","issue_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/809","number":809,"state":"open","locked":false,"title":"IA Pages - make sure the ID (and meta_id) doesn't have weird chars in it before saving","user":{"login":"MariagraziaAlastra","id":3652195,"avatar_url":"https://avatars.githubusercontent.com/u/3652195?v=3","gravatar_id":"","url":"https://api.github.com/users/MariagraziaAlastra","html_url":"https://github.com/MariagraziaAlastra","followers_url":"https://api.github.com/users/MariagraziaAlastra/followers","following_url":"https://api.github.com/users/MariagraziaAlastra/following{/other_user}","gists_url":"https://api.github.com/users/MariagraziaAlastra/gists{/gist_id}","starred_url":"https://api.github.com/users/MariagraziaAlastra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MariagraziaAlastra/subscriptions","organizations_url":"https://api.github.com/users/MariagraziaAlastra/orgs","repos_url":"https://api.github.com/users/MariagraziaAlastra/repos","events_url":"https://api.github.com/users/MariagraziaAlastra/events{/privacy}","received_events_url":"https://api.github.com/users/MariagraziaAlastra/received_events","type":"User","site_admin":false},"body":"@russellholt @jagtalon the check happens when creating a new IA Page and also when editing the meta_id both on the dev pages and the live pages; any non-alphanumeric char gets replaced by an underscore, unless they're at the beginning or end of the string: in that case they get cut off entirely.\r\n\r\nThe ID can have numbers in it, but they can't be at the beginning of the string, and they need to be mixed with alphabetic (a-z) chars.\r\n\r\nIf the string only contains weird chars and/or numbers, it gets emptied, so the caller won't save it.\r\n\r\nAlso, now inside the dialog for creating a new IA Page the ID input field turns red if the entered string is invalid and thus the page is not created.\r\n\r\n![screenshot-maria duckduckgo com 5001 2015-07-02 17-13-51](https://cloud.githubusercontent.com/assets/3652195/8480420/ca882caa-20dd-11e5-8813-ddd92e83d3dd.png)\r\n","created_at":"2015-07-02T15:15:02Z","updated_at":"2015-07-02T15:59:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"98bb3d3975ecf930fa29ca6f062e9d40ebbcd451","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809/commits","review_comments_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809/comments","review_comment_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/809/comments","statuses_url":"https://api.github.com/repos/duckduckgo/community-platform/statuses/f66028ea58c5dc983f52553f9f86a48adb8dd8a2","head":{"label":"duckduckgo:maria/check_id","ref":"maria/check_id","sha":"f66028ea58c5dc983f52553f9f86a48adb8dd8a2","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":1751775,"name":"community-platform","full_name":"duckduckgo/community-platform","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/community-platform","description":"DuckDuckGo Community Platform","fork":false,"url":"https://api.github.com/repos/duckduckgo/community-platform","forks_url":"https://api.github.com/repos/duckduckgo/community-platform/forks","keys_url":"https://api.github.com/repos/duckduckgo/community-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/community-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/community-platform/teams","hooks_url":"https://api.github.com/repos/duckduckgo/community-platform/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/community-platform/events","assignees_url":"https://api.github.com/repos/duckduckgo/community-platform/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/community-platform/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/community-platform/tags","blobs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/community-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/community-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/community-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/community-platform/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/community-platform/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/community-platform/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/community-platform/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/community-platform/subscription","commits_url":"https://api.github.com/repos/duckduckgo/community-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/community-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/community-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/community-platform/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/community-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/community-platform/merges","archive_url":"https://api.github.com/repos/duckduckgo/community-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/community-platform/downloads","issues_url":"https://api.github.com/repos/duckduckgo/community-platform/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/community-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/community-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/community-platform/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/community-platform/releases{/id}","created_at":"2011-05-15T17:35:41Z","updated_at":"2015-06-29T14:44:55Z","pushed_at":"2015-07-02T15:54:16Z","git_url":"git://github.com/duckduckgo/community-platform.git","ssh_url":"git@github.com:duckduckgo/community-platform.git","clone_url":"https://github.com/duckduckgo/community-platform.git","svn_url":"https://github.com/duckduckgo/community-platform","homepage":"https://duck.co/","size":37175,"stargazers_count":350,"watchers_count":350,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":120,"forks":88,"open_issues":120,"watchers":350,"default_branch":"master"}},"base":{"label":"duckduckgo:dev-ia-pages","ref":"dev-ia-pages","sha":"e6b8cb347e86f47907dc7b756233b6cf4a0936ce","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":1751775,"name":"community-platform","full_name":"duckduckgo/community-platform","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/community-platform","description":"DuckDuckGo Community Platform","fork":false,"url":"https://api.github.com/repos/duckduckgo/community-platform","forks_url":"https://api.github.com/repos/duckduckgo/community-platform/forks","keys_url":"https://api.github.com/repos/duckduckgo/community-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/community-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/community-platform/teams","hooks_url":"https://api.github.com/repos/duckduckgo/community-platform/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/community-platform/events","assignees_url":"https://api.github.com/repos/duckduckgo/community-platform/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/community-platform/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/community-platform/tags","blobs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/community-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/community-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/community-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/community-platform/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/community-platform/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/community-platform/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/community-platform/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/community-platform/subscription","commits_url":"https://api.github.com/repos/duckduckgo/community-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/community-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/community-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/community-platform/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/community-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/community-platform/merges","archive_url":"https://api.github.com/repos/duckduckgo/community-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/community-platform/downloads","issues_url":"https://api.github.com/repos/duckduckgo/community-platform/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/community-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/community-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/community-platform/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/community-platform/releases{/id}","created_at":"2011-05-15T17:35:41Z","updated_at":"2015-06-29T14:44:55Z","pushed_at":"2015-07-02T15:54:16Z","git_url":"git://github.com/duckduckgo/community-platform.git","ssh_url":"git@github.com:duckduckgo/community-platform.git","clone_url":"https://github.com/duckduckgo/community-platform.git","svn_url":"https://github.com/duckduckgo/community-platform","homepage":"https://duck.co/","size":37175,"stargazers_count":350,"watchers_count":350,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":120,"forks":88,"open_issues":120,"watchers":350,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809"},"html":{"href":"https://github.com/duckduckgo/community-platform/pull/809"},"issue":{"href":"https://api.github.com/repos/duckduckgo/community-platform/issues/809"},"comments":{"href":"https://api.github.com/repos/duckduckgo/community-platform/issues/809/comments"},"review_comments":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809/comments"},"review_comment":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/809/commits"},"statuses":{"href":"https://api.github.com/repos/duckduckgo/community-platform/statuses/f66028ea58c5dc983f52553f9f86a48adb8dd8a2"}}}}