Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON file with html content detected as text/html since v1.0.0 #79

Open
adamzapasnik opened this issue Oct 17, 2022 · 1 comment
Open

Comments

@adamzapasnik
Copy link

Hello, I've noticed that json files with html content are reported as text/html, which isn't correct, is it?. Accidentally, I tested also against v0.3.3 and it reported it correctly as application/json, so one could say it's a regression?

I'm raising this issue, but not sure if it's fixable or if it's even a bug? 🙈

require 'bundler/inline'
require "stringio"

gemfile do
  source 'https://rubygems.org'
  gem 'marcel', '1.0.2'
  # gem 'marcel', '0.3.3'
end

puts Marcel::VERSION
string = StringIO.new('{"a": "b"}')
puts string.read + ": " + Marcel::MimeType.for(string, name: "test.json")
string = StringIO.new('{"a": "<html"}')
puts string.read + ": " + Marcel::MimeType.for(string, name: "test.json")
string = StringIO.new('{"a": "<htm"}')
puts string.read + ": " + Marcel::MimeType.for(string, name: "test.json")

output for 1.0.2:

1.0.2
{"a": "b"}: application/json
{"a": "<html"}: text/html
{"a": "<htm"}: application/json

output for 0.3.3

0.3.3
{"a": "b"}: application/json
{"a": "<html"}: application/json
{"a": "<htm"}: application/json

Let me know if you need help with this 😅

@janklimo
Copy link

Seeing something similar with HTML data in CSV:

Marcel::VERSION
# => "1.0.2"
string = StringIO.new('a,b,c,d,<html><u>category</u>:description</html>')
Marcel::MimeType.for(string, name: "test.csv")
# => "text/html"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants