[buck] fix target quoting regexp

Summary:
The check for whether a buck target needs quoting is incorrect, since it uses `-` inside a character class to denote a dash, not a character range. The correct way to do this is to put the dash as the first character in the class (or last).

Facebook

iknowthis_regex

Reviewed By: jberdine

Differential Revision: D20159112

fbshipit-source-id: be6750ed8
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent 7deaae6598
commit 6c8036e6c0

@ -77,7 +77,7 @@ module Query = struct
exception NotATarget exception NotATarget
let quote_if_needed = let quote_if_needed =
let no_quote_needed_regexp = Str.regexp "^[a-zA-Z0-9/:_*][a-zA-Z0-9/:.-_*]*$" in let no_quote_needed_regexp = Str.regexp "^[a-zA-Z0-9/:_*][-a-zA-Z0-9/:._*]*$" in
fun s -> fun s ->
if Str.string_match no_quote_needed_regexp s 0 then s if Str.string_match no_quote_needed_regexp s 0 then s
else s |> Escape.escape_double_quotes |> F.sprintf "\"%s\"" else s |> Escape.escape_double_quotes |> F.sprintf "\"%s\""

Loading…
Cancel
Save