aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
diff options
context:
space:
mode:
authorGravatar carmi <carmi@google.com>2018-04-10 12:40:14 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-10 12:41:19 -0700
commitca598fb9445627e9734c2900bc6b11430250d453 (patch)
tree233680bba78de8936004ccf027f94c3245973cc6 /src/main/java/com/google/devtools/build/lib/cmdline/Label.java
parent2399df0dd858f24ce18b4ee85faa569d6b0bb19a (diff)
Disallow labels of the form ////foo.
RELNOTES: Labels of the form ////foo are disallowed. PiperOrigin-RevId: 192329081
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/cmdline/Label.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/cmdline/Label.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
index f271ea6c8b..92969c4111 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
@@ -257,11 +257,14 @@ public final class Label
*/
private static PackageIdentifier validatePackageName(String packageIdentifier, String name)
throws LabelSyntaxException {
- String error = null;
+ if (packageIdentifier.startsWith("/")) {
+ throw new LabelSyntaxException(
+ "package names may not start with '/' (do you have too many '/'?)");
+ }
try {
return PackageIdentifier.parse(packageIdentifier);
} catch (LabelSyntaxException e) {
- error = e.getMessage();
+ String error = e.getMessage();
error = "invalid package name '" + packageIdentifier + "': " + error;
// This check is just for a more helpful error message
// i.e. valid target name, invalid package name, colon-free label form