webmachine-ruby icon indicating copy to clipboard operation
webmachine-ruby copied to clipboard

Webmachine::QuotedString#quote fails when trying to quote `request.if_match` when it's nil

Open jfredett opened this issue 11 years ago • 1 comments

My resource ends up failing in state g9 because request.if_match is nil. This can be fixed by changing:

        # Escapes quotes within a quoted string.
        def escape_quotes(str)
          str.gsub(/"/, '\\"')
        end

        # Unescapes quotes within a quoted string
        def unescape_quotes(str)
          str.gsub(%r{\\}, '')
        end

with

        # Escapes quotes within a quoted string.
        def escape_quotes(str)
          String(str).gsub(/"/, '\\"')
        end

        # Unescapes quotes within a quoted string
        def unescape_quotes(str)
          String(str).gsub(%r{\\}, '')
        end

But I'm not totally confident I'm doing everything correctly. Totally willing to make the change, but I want to confirm that this is, indeed, unexpected behavior. At the very least, this seems to cause a 415 to be returned, even though I suspect it should return something in the 500-series (since this is a server-side problem).

jfredett avatar Oct 30 '14 15:10 jfredett

Pull Req above if you want it. I also added some specs around this module. Details in the PR

jfredett avatar Oct 30 '14 16:10 jfredett