laserlemon/simple_oauth — pull request #14 by notEthan (2014-03-12 17:05:42+00:00)
Title: refactor .parse for robustness

following #13 I have noticed a couple other issues, all of which I've fixed by refactoring `.parse`.

- a badly formed Authorization header results in the rather unuseful error `NoMethodError: undefined method '[]' for nil:NilClass`. I've reworked things to raise a SimpleOauth::ParseError with a relatively informative message.
- while other characters may be passed in without proper escaping (despite this not being strictly valid per the OAuth spec), commas passed in unescaped break the parsing. I've changed to allow unescaped commas the same as any other character. this necessitated a change to use a StringScanner rather than simply splitting, which I think makes the whole thing more robust.
- Authorization header params prefixed with `oauth_` are treated the same as those without the `oauth_` prefix. I check that all params are properly prefixed with `oauth_` and raise ParseError if not.