Skip to content

Commit 6524848

Browse files
manickithiemowmde
authored andcommitted
Disallow periods in repository names (#737)
Periods would be confusing when entity ID is used in URIs/URLs as they might be considered "separators" of parts of URL/URI. Also periods are about to be used instead of colons in "chained" entity IDs in cases where colons are not allowed (e.g. RDF).
1 parent 96d14c6 commit 6524848

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/Assert/RepositoryNameAssert.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RepositoryNameAssert {
2828
*/
2929
public static function assertParameterIsValidRepositoryName( $value, $name ) {
3030
if ( !self::isValidRepositoryName( $value ) ) {
31-
throw new ParameterAssertionException( $name, 'must be a string not including colons' );
31+
throw new ParameterAssertionException( $name, 'must be a string not including colons nor periods' );
3232
}
3333
}
3434

@@ -51,7 +51,7 @@ public static function assertParameterKeysAreValidRepositoryNames( $values, $nam
5151
if ( !self::isValidRepositoryName( $key ) ) {
5252
throw new ParameterAssertionException(
5353
"array_keys( $name )",
54-
'must not contain strings including colons'
54+
'must not contain strings including colons or periods'
5555
);
5656
}
5757
}
@@ -62,7 +62,7 @@ public static function assertParameterKeysAreValidRepositoryNames( $values, $nam
6262
* @return bool
6363
*/
6464
private static function isValidRepositoryName( $value ) {
65-
return is_string( $value ) && strpos( $value, ':' ) === false;
65+
return is_string( $value ) && strpos( $value, ':' ) === false && strpos( $value, '.' ) === false;
6666
}
6767

6868
}

tests/unit/Assert/RepositoryNameAssertTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public function provideInvalidRepositoryNames() {
1818
[ 'foo:' ],
1919
[ ':foo' ],
2020
[ ':' ],
21+
[ 'fo.o' ],
22+
[ 'foo.' ],
23+
[ '.foo' ],
24+
[ '.' ],
2125
[ 123 ],
2226
[ null ],
2327
[ false ],

0 commit comments

Comments
 (0)