Recompile all regexes.

Compiled regexes are endianness-specific. To run on any endianness
systems we need to recompile them in runtime.
This commit is contained in:
Daniil Fedotov 2019-05-07 11:29:40 -04:00
parent 528ce15e79
commit 992e6810d2
3 changed files with 9 additions and 5 deletions

View File

@ -179,7 +179,8 @@ defmodule RabbitMQ.CLI.Core.Listeners do
# This simplistic way of distinguishing IPv6 addresses,
# networks address ranges, etc actually works better
# for the kind of values we can get here than :inet functions. MK.
case value =~ ~r/:/ do
regex = Regex.recompile!(~r/:/)
case value =~ regex do
true -> "[#{value}]"
false -> value
end

View File

@ -290,8 +290,8 @@ short | long | description
end
end
defp strip_rabbitmq_prefix(value) do
Regex.replace(~r/^rabbitmq_/, value, "")
defp strip_rabbitmq_prefix(value, regex) do
Regex.replace(regex, value, "")
end
defp format_known_plugin_name_fragments(value) do
@ -310,9 +310,11 @@ short | long | description
end
defp plugin_section(plugin) do
regex = Regex.recompile!(~r/^rabbitmq_/)
to_string(plugin)
# drop rabbitmq_
|> strip_rabbitmq_prefix()
|> strip_rabbitmq_prefix(regex)
|> String.split("_")
|> format_known_plugin_name_fragments()
end

View File

@ -15,7 +15,8 @@
defmodule RabbitMQ.CLI.Diagnostics.Helpers do
def check_port_connectivity(port, node_name, timeout) do
hostname = Regex.replace(~r/^(.+)@/, to_string(node_name), "") |> to_charlist
regex = Regex.recompile!(~r/^(.+)@/)
hostname = Regex.replace(regex, to_string(node_name), "") |> to_charlist
try do
case :gen_tcp.connect(hostname, port, [], timeout) do