Giter Site home page Giter Site logo

content_type.rb's Issues

We ran into a SystemStackError error on production

Just FYI, I've tried to use this gem on production yeat ran into a SystemStackError that brough down production for couple of hours. I was unable to reproduce this error locally, but managed to fish our error from logs:

/usr/local/bundle/gems/content-type-0.0.1/lib/content_type/parser.rb:30:in `to_s': stack level too deep (SystemStackError)
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet/atoms/str.rb:13:in `escape'
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet/atoms/str.rb:13:in `initialize'
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet.rb:157:in `new'
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet.rb:157:in `str'
  from /usr/local/bundle/gems/content-type-0.0.1/lib/content_type/parser.rb:64:in `block in <class:Parser>'
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet.rb:110:in `instance_eval'
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet.rb:110:in `block (2 levels) in rule'
  from /usr/local/bundle/gems/parslet-1.8.2/lib/parslet/atoms/entity.rb:28:in `parslet'
 ... 10188 levels...
  from /usr/local/bundle/gems/bundler-2.3.6/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
  from /usr/local/bundle/gems/bundler-2.3.6/exe/bundle:36:in `<top (required)>'
  from /usr/local/bundle/bin/bundle:23:in `load'
  from /usr/local/bundle/bin/bundle:23:in `<main>'

Fails to parse types containing '.' like vnd.*

ContentType fails to correctly parse content types containing ., which appear to have been valid from the first mediatypes RFCs.

>> ContentType.parse("application/vnd.oasis.opendocument.text")
Parslet::ParseFailed: Failed to match sequence (type:TYPE '/' subtype:SUBTYPE PARAMETERS{0, }) at line 1 char 16.
0: gems/parslet-1.8.0/lib/parslet/cause.rb:70:in `raise'
1: gems/parslet-1.8.0/lib/parslet/atoms/base.rb:49:in `parse'
2: gems/content-type-0.0.1/lib/content_type.rb:39:in `parse'

https://tools.ietf.org/html/rfc6838#section-3.2
https://www.iana.org/assignments/media-types/media-types.xhtml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.