Module: Mail::Parsers::ContentTransferEncodingParser
- Extended by:
- Mail::ParserTools
- Defined in:
- lib/mail/parsers/content_transfer_encoding_parser.rb
Defined Under Namespace
Classes: ContentTransferEncodingStruct
Class Attribute Summary collapse
-
._eof_actions ⇒ Object
Returns the value of attribute _eof_actions.
-
._index_offsets ⇒ Object
Returns the value of attribute _index_offsets.
-
._indicies ⇒ Object
Returns the value of attribute _indicies.
-
._key_spans ⇒ Object
Returns the value of attribute _key_spans.
-
._trans_actions ⇒ Object
Returns the value of attribute _trans_actions.
-
._trans_keys ⇒ Object
Returns the value of attribute _trans_keys.
-
._trans_targs ⇒ Object
Returns the value of attribute _trans_targs.
-
.en_comment_tail ⇒ Object
Returns the value of attribute en_comment_tail.
-
.en_main ⇒ Object
Returns the value of attribute en_main.
-
.error ⇒ Object
Returns the value of attribute error.
-
.first_final ⇒ Object
Returns the value of attribute first_final.
-
.start ⇒ Object
Returns the value of attribute start.
Class Method Summary collapse
Methods included from Mail::ParserTools
Class Attribute Details
._eof_actions ⇒ Object
Returns the value of attribute _eof_actions.
301 302 303 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 301 def _eof_actions @_eof_actions end |
._index_offsets ⇒ Object
Returns the value of attribute _index_offsets.
42 43 44 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 42 def _index_offsets @_index_offsets end |
._indicies ⇒ Object
Returns the value of attribute _indicies.
53 54 55 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 53 def _indicies @_indicies end |
._key_spans ⇒ Object
Returns the value of attribute _key_spans.
31 32 33 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 31 def _key_spans @_key_spans end |
._trans_actions ⇒ Object
Returns the value of attribute _trans_actions.
287 288 289 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 287 def _trans_actions @_trans_actions end |
._trans_keys ⇒ Object
Returns the value of attribute _trans_keys.
13 14 15 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 13 def _trans_keys @_trans_keys end |
._trans_targs ⇒ Object
Returns the value of attribute _trans_targs.
273 274 275 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 273 def _trans_targs @_trans_targs end |
.en_comment_tail ⇒ Object
Returns the value of attribute en_comment_tail.
325 326 327 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 325 def en_comment_tail @en_comment_tail end |
.en_main ⇒ Object
Returns the value of attribute en_main.
329 330 331 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 329 def en_main @en_main end |
.error ⇒ Object
Returns the value of attribute error.
320 321 322 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 320 def error @error end |
.first_final ⇒ Object
Returns the value of attribute first_final.
316 317 318 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 316 def first_final @first_final end |
.start ⇒ Object
Returns the value of attribute start.
312 313 314 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 312 def start @start end |
Class Method Details
.parse(data) ⇒ Object
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/mail/parsers/content_transfer_encoding_parser.rb', line 333 def self.parse(data) data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding) content_transfer_encoding = ContentTransferEncodingStruct.new("") return content_transfer_encoding if Mail::Utilities.blank?(data) # Parser state encoding_s = nil # 5.1 Variables Used by Ragel p = 0 eof = pe = data.length stack = [] begin p ||= 0 pe ||= data.length cs = start top = 0 end begin testEof = false _slen, _trans, _keys, _inds, _acts, _nacts = nil _goto_level = 0 _resume = 10 _eof_trans = 15 _again = 20 _test_eof = 30 _out = 40 while true if _goto_level <= 0 if p == pe _goto_level = _test_eof next end if cs == 0 _goto_level = _out next end end if _goto_level <= _resume _keys = cs << 1 _inds = _index_offsets[cs] _slen = _key_spans[cs] _wide = data[p].ord _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) _indicies[_inds + _wide - _trans_keys[_keys]] else _indicies[_inds + _slen] end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] when 1 begin encoding_s = p end when 10 begin content_transfer_encoding.encoding = chars(data, encoding_s, p - 1).downcase end when 3 begin end when 6 begin end when 2 begin begin stack[top] = cs top += 1 cs = 9 _goto_level = _again next end end when 9 begin begin top -= 1 cs = stack[top] _goto_level = _again next end end when 11 begin content_transfer_encoding.encoding = chars(data, encoding_s, p - 1).downcase end begin begin stack[top] = cs top += 1 cs = 9 _goto_level = _again next end end when 4 begin end begin encoding_s = p end when 5 begin end begin begin stack[top] = cs top += 1 cs = 9 _goto_level = _again next end end when 7 begin end begin begin stack[top] = cs top += 1 cs = 9 _goto_level = _again next end end when 8 begin end begin begin top -= 1 cs = stack[top] _goto_level = _again next end end end end end if _goto_level <= _again if cs == 0 _goto_level = _out next end p += 1 if p != pe _goto_level = _resume next end end if _goto_level <= _test_eof if p == eof case _eof_actions[cs] when 10 begin content_transfer_encoding.encoding = chars(data, encoding_s, p - 1).downcase end when 3 begin end end end end if _goto_level <= _out break end end end if p != eof || cs < 21 raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p) end content_transfer_encoding end |