Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15430916
D14872.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14872.diff
View Options
diff --git a/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php b/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
--- a/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
+++ b/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
@@ -310,7 +310,6 @@
$slugs = mpull($slugs, 'getSlug');
$this->assertTrue(in_array($name2, $slugs));
-
}
public function testDuplicateSlugs() {
diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
--- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
+++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
@@ -268,6 +268,17 @@
}
$name = last($xactions)->getNewValue();
+
+ if (!PhabricatorSlug::isValidProjectSlug($name)) {
+ $errors[] = new PhabricatorApplicationTransactionValidationError(
+ $type,
+ pht('Invalid'),
+ pht(
+ 'Project names must contain at least one letter or number.'),
+ last($xactions));
+ break;
+ }
+
$name_used_already = id(new PhabricatorProjectQuery())
->setViewer($this->getActor())
->withNames(array($name))
@@ -304,6 +315,27 @@
$slug_xaction = last($xactions);
$new = $slug_xaction->getNewValue();
+
+ $invalid = array();
+ foreach ($new as $slug) {
+ if (!PhabricatorSlug::isValidProjectSlug($slug)) {
+ $invalid[] = $slug;
+ }
+ }
+
+ if ($invalid) {
+ $errors[] = new PhabricatorApplicationTransactionValidationError(
+ $type,
+ pht('Invalid'),
+ pht(
+ 'Hashtags must contain at least one letter or number. %s '.
+ 'project hashtag(s) are invalid: %s.',
+ phutil_count($invalid),
+ implode(', ', $invalid)),
+ $slug_xaction);
+ break;
+ }
+
$new = $this->normalizeSlugs($new);
if ($new) {
diff --git a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
--- a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
+++ b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
@@ -774,6 +774,14 @@
'%s changed project hashtag(s), added %d: %s; removed %d: %s.' =>
'%s changed project hashtags, added %3$s; removed %5$s.',
+ 'Hashtags must contain at least one letter or number. %s '.
+ 'project hashtag(s) are invalid: %s.' => array(
+ 'Hashtags must contain at least one letter or number. The '.
+ 'hashtag "%2$s" is not valid.',
+ 'Hashtags must contain at least one letter or number. These '.
+ 'hashtags are invalid: %2$s.',
+ ),
+
'%s added %d project hashtag(s): %s.' => array(
array(
'%s added a hashtag: %3$s.',
diff --git a/src/infrastructure/util/PhabricatorSlug.php b/src/infrastructure/util/PhabricatorSlug.php
--- a/src/infrastructure/util/PhabricatorSlug.php
+++ b/src/infrastructure/util/PhabricatorSlug.php
@@ -8,6 +8,11 @@
return rtrim($slug, '/');
}
+ public static function isValidProjectSlug($slug) {
+ $slug = self::normalizeProjectSlug($slug);
+ return ($slug != '_');
+ }
+
public static function normalize($slug, $hashtag = false) {
$slug = preg_replace('@/+@', '/', $slug);
$slug = trim($slug, '/');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 25, 9:37 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7328551
Default Alt Text
D14872.diff (3 KB)
Attached To
Mode
D14872: Improve error messages for bad hashtags and project names
Attached
Detach File
Event Timeline
Log In to Comment