From 9f4fb95093b9a3d7d78d2e76f4176ec98e4f269d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 23 Sep 2025 18:59:52 +0100 Subject: [PATCH] Fix identification of bzip2 compressed traces Marcel 1.1.0 stops bzip2 wrongly matching as bzip but it's new rule for bzip2 is buggy so we have to add our own rule for now. https://github.com/rails/marcel/issues/128 --- config/initializers/marcel.rb | 15 +++++++++++++++ lib/gpx.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 config/initializers/marcel.rb diff --git a/config/initializers/marcel.rb b/config/initializers/marcel.rb new file mode 100644 index 000000000..aec915123 --- /dev/null +++ b/config/initializers/marcel.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +Marcel::MimeType.extend "application/x-bzip2", + :extensions => %w[bz2 tbz2 boz], + :magic => [ + [0, "BZh1"], + [0, "BZh2"], + [0, "BZh3"], + [0, "BZh4"], + [0, "BZh5"], + [0, "BZh6"], + [0, "BZh7"], + [0, "BZh8"], + [0, "BZh9"] + ] diff --git a/lib/gpx.rb b/lib/gpx.rb index 058c1d990..6fb347ca8 100644 --- a/lib/gpx.rb +++ b/lib/gpx.rb @@ -60,7 +60,7 @@ module GPX case Marcel::MimeType.for(io) when "application/gzip" then io = Zlib::GzipReader.open(@file) - when "application/x-bzip" then io = Bzip2::FFI::Reader.open(@file) + when "application/x-bzip2" then io = Bzip2::FFI::Reader.open(@file) end parse_file(XML::Reader.io(io, :options => XML::Parser::Options::NOERROR), &block) -- 2.39.5