fix error with wrong encoding or error in YAML #498

Closed
wants to merge 2 commits into
from

Projects

None yet

5 participants

@stereobooster

before

/psych.rb:148:in `parse': couldn't parse YAML at line 9 column 0 (Psych::SyntaxError)
        from /psych.rb:148:in `parse_stream'
        from /psych.rb:119:in `parse'
        from /psych.rb:106:in `load'
        from /lib/jekyll/convertible.rb:33:in `read_yaml'
        from /lib/jekyll/post.rb:41:in `initialize'
        from /lib/jekyll/site.rb:166:in `new'
        from /lib/jekyll/site.rb:166:in `block in read_posts'
        from /lib/jekyll/site.rb:164:in `each'
        from /lib/jekyll/site.rb:164:in `read_posts'
        from /lib/jekyll/site.rb:131:in `read_directories'
        from /lib/jekyll/site.rb:101:in `read'
        from /lib/jekyll/site.rb:39:in `process'
        from /bin/jekyll:254:in `<top (required)>'
        from /bin/jekyll:19:in `load'
        from /bin/jekyll:19:in `<main>'

after

YAML Exception reading 2012-01-02-microformats.html: couldn't parse YAML at line 9 column 0
@stereobooster

connected with #188, fix #248

@stereobooster
rescue => e

is synonym to

rescue StandardError => e

But psych raise Psych::SyntaxError which is subclass of ::SyntaxError

Exception
  ScriptError
    SyntaxError
  StandardError

This is clearly a small bug. Can this small fix be merged?

@stereobooster

@svnpenn did error message became clearer? That is what my patch about.

@svnpenn

No, this one

convertible.rb:26:in `read_yaml': invalid byte sequence in UTF-8 (ArgumentError)
@stereobooster

To fix this, you need to change (in convertible.rb)

    def read_yaml(base, name)
      self.content = File.read(File.join(base, name))

      begin
        if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m

to

    def read_yaml(base, name)
      begin
        self.content = File.read(File.join(base, name))
        if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m

Didn't test it. But it should be it.

@gerardc

Any updates on this request? It seems like a solid fix

@parkr
Jekyll member

Biiiiiiiiig ups. 👍

@parkr
Jekyll member

@stereobooster, can you commit these to a patch/feature branch and re-submit? Going master-to-master is usually not the best plan ever.

@parkr parkr referenced this pull request Dec 8, 2012
Closed

YAML Error Messages #248

@rsanheim

👍

@parkr
Jekyll member

Please rebase on the current master and re-submit from a feature branch, not master. Re-submit the PR and I'll bring it to @mojombo's attention.

@parkr parkr closed this Dec 26, 2012
@parkr
Jekyll member

(I've made note of this PR in case you don't re-submit, @stereobooster, as these changes are desired.)

@stereobooster

I will resubmit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment