Method: Mechanize::HTTP::ContentDispositionParser#rfc_2045_quoted_string

Defined in:
lib/mechanize/http/content_disposition_parser.rb

#rfc_2045_quoted_stringObject

quoted-string = <“> *(qtext/quoted-pair) <”>

qtext         = <any CHAR excepting <">, "\" & CR,
                 and including linear-white-space
quoted-pair   = "\" CHAR

Parses an RFC 2045 quoted-string

[View source]

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/mechanize/http/content_disposition_parser.rb', line 137

def rfc_2045_quoted_string
  return nil unless @scanner.scan(/"/)

  text = String.new

  while true do
    chunk = @scanner.scan(/[\000-\014\016-\041\043-\133\135-\177]+/) # not \r "

    if chunk then
      text << chunk

      if @scanner.peek(1) == '\\' then
        @scanner.get_byte
        return nil if @scanner.eos?
        text << @scanner.get_byte
      elsif @scanner.scan(/\r\n[\t ]+/) then
        text << " "
      end
    else
      if '\\"' == @scanner.peek(2) then
        @scanner.skip(/\\/)
        text << @scanner.get_byte
      elsif '"' == @scanner.peek(1) then
        @scanner.get_byte
        break
      else
        return nil
      end
    end
  end

  text
end