Skip to content

Commit e6c1f73

Browse files
committed
Drop dependency on xmerl where it isn't needed
UTF-8 validation that used xmerl_ucs:from_bin/1 now uses unicode:characters_to_binary/3.
1 parent 1f909ed commit e6c1f73

File tree

8 files changed

+19
-15
lines changed

8 files changed

+19
-15
lines changed

deps/amqp_client/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ endef
3939
# Release artifacts are put in $(PACKAGES_DIR).
4040
PACKAGES_DIR ?= $(abspath PACKAGES)
4141

42-
LOCAL_DEPS = xmerl ssl public_key
42+
LOCAL_DEPS = ssl public_key
4343
DEPS = rabbit_common credentials_obfuscation
4444
TEST_DEPS = rabbitmq_ct_helpers rabbit meck
4545

deps/amqp_client/src/amqp_connection.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ set_connection_name(ConnName,
203203
%% application controller is in the process of shutting down the very
204204
%% application which is making this call.
205205
ensure_started() ->
206-
[ensure_started(App) || App <- [syntax_tools, compiler, xmerl,
206+
[ensure_started(App) || App <- [syntax_tools, compiler,
207207
rabbit_common, amqp_client, credentials_obfuscation]],
208208
ok.
209209

deps/rabbit/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ define PROJECT_ENV
126126
]
127127
endef
128128

129-
LOCAL_DEPS = sasl os_mon inets compiler public_key crypto ssl syntax_tools xmerl
129+
LOCAL_DEPS = sasl os_mon inets compiler public_key crypto ssl syntax_tools
130130

131131
BUILD_DEPS = rabbitmq_cli
132132
DEPS = ranch cowlib rabbit_common amqp10_common rabbitmq_prelaunch ra sysmon_handler stdout_formatter recon redbug observer_cli osiris syslog systemd seshat horus khepri khepri_mnesia_migration cuttlefish gen_batch_server

deps/rabbit_common/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define HEX_TARBALL_EXTRA_METADATA
2525
}
2626
endef
2727

28-
LOCAL_DEPS = compiler crypto public_key sasl ssl syntax_tools tools xmerl runtime_tools
28+
LOCAL_DEPS = compiler crypto public_key sasl ssl syntax_tools tools runtime_tools
2929
DEPS = thoas ranch recon credentials_obfuscation
3030

3131
# Variables and recipes in development.*.mk are meant to be used from
@@ -43,7 +43,7 @@ DEP_EARLY_PLUGINS = $(PROJECT)/mk/rabbitmq-early-plugin.mk
4343
DEP_PLUGINS = $(PROJECT)/mk/rabbitmq-build.mk \
4444
$(PROJECT)/mk/rabbitmq-hexpm.mk
4545

46-
PLT_APPS += mnesia crypto ssl xmerl
46+
PLT_APPS += mnesia crypto ssl
4747

4848
include ../../rabbitmq-components.mk
4949
include ../../erlang.mk

deps/rabbit_common/src/rabbit_binary_parser.erl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ assert_utf8(B) ->
164164
end.
165165

166166
validate_utf8(Bin) ->
167-
try
168-
_ = xmerl_ucs:from_utf8(Bin),
169-
ok
170-
catch exit:{ucs, _} ->
167+
case unicode:characters_to_binary(Bin, unicode, unicode) of
168+
B when is_binary(B) ->
169+
ok;
170+
{error, _, _} ->
171+
error;
172+
{incomplete, _, _} ->
171173
error
172174
end.

deps/rabbit_common/src/rabbit_misc.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,13 @@ b64decode_or_throw(B64) ->
505505
end.
506506

507507
utf8_safe(V) ->
508-
try
509-
_ = xmerl_ucs:from_utf8(V),
510-
V
511-
catch exit:{ucs, _} ->
508+
case unicode:characters_to_binary(V, unicode, unicode) of
509+
B when is_binary(B) ->
510+
B;
511+
{error, _, _} ->
512+
Enc = split_lines(base64:encode(V)),
513+
<<"Not UTF-8, base64 is: ", Enc/binary>>;
514+
{incomplete, _, _} ->
512515
Enc = split_lines(base64:encode(V)),
513516
<<"Not UTF-8, base64 is: ", Enc/binary>>
514517
end.

deps/rabbitmq_cli/test/test_helper.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ if function_exported?(Mix, :ensure_application!, 1) do
3535
Mix.ensure_application!(:public_key)
3636
Mix.ensure_application!(:runtime_tools)
3737
Mix.ensure_application!(:sasl)
38-
Mix.ensure_application!(:xmerl)
3938
end
4039

4140
defmodule TestHelper do

deps/rabbitmq_management_agent/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ endef
1919

2020
DEPS = rabbit_common rabbit rabbitmq_web_dispatch
2121
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers
22-
LOCAL_DEPS += xmerl ranch ssl crypto public_key
22+
LOCAL_DEPS += ranch ssl crypto public_key
2323

2424
PLT_APPS += rabbitmq_cli
2525

0 commit comments

Comments
 (0)