Module: Mail::Parsers::ContentDispositionParser

Defined in:
lib/mail/parsers/content_disposition_parser.rb

Defined Under Namespace

Classes: ContentDispositionStruct

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

._eof_actionsObject

Returns the value of attribute _eof_actions



344
345
346
# File 'lib/mail/parsers/content_disposition_parser.rb', line 344

def _eof_actions
  @_eof_actions
end

._index_offsetsObject

Returns the value of attribute _index_offsets



46
47
48
# File 'lib/mail/parsers/content_disposition_parser.rb', line 46

def _index_offsets
  @_index_offsets
end

._indiciesObject

Returns the value of attribute _indicies



58
59
60
# File 'lib/mail/parsers/content_disposition_parser.rb', line 58

def _indicies
  @_indicies
end

._key_spansObject

Returns the value of attribute _key_spans



34
35
36
# File 'lib/mail/parsers/content_disposition_parser.rb', line 34

def _key_spans
  @_key_spans
end

._trans_actionsObject

Returns the value of attribute _trans_actions



328
329
330
# File 'lib/mail/parsers/content_disposition_parser.rb', line 328

def _trans_actions
  @_trans_actions
end

._trans_keysObject

Returns the value of attribute _trans_keys



14
15
16
# File 'lib/mail/parsers/content_disposition_parser.rb', line 14

def _trans_keys
  @_trans_keys
end

._trans_targsObject

Returns the value of attribute _trans_targs



312
313
314
# File 'lib/mail/parsers/content_disposition_parser.rb', line 312

def _trans_targs
  @_trans_targs
end

.en_comment_tailObject

Returns the value of attribute en_comment_tail



369
370
371
# File 'lib/mail/parsers/content_disposition_parser.rb', line 369

def en_comment_tail
  @en_comment_tail
end

.en_mainObject

Returns the value of attribute en_main



373
374
375
# File 'lib/mail/parsers/content_disposition_parser.rb', line 373

def en_main
  @en_main
end

.errorObject

Returns the value of attribute error



364
365
366
# File 'lib/mail/parsers/content_disposition_parser.rb', line 364

def error
  @error
end

.first_finalObject

Returns the value of attribute first_final



360
361
362
# File 'lib/mail/parsers/content_disposition_parser.rb', line 360

def first_final
  @first_final
end

.startObject

Returns the value of attribute start



356
357
358
# File 'lib/mail/parsers/content_disposition_parser.rb', line 356

def start
  @start
end

Class Method Details

.parse(data) ⇒ Object



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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/mail/parsers/content_disposition_parser.rb', line 379

def self.parse(data)
  content_disposition = ContentDispositionStruct.new('', [])
  return content_disposition if Mail::Utilities.blank?(data)

  # Parser state
  disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_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] 
  ) then
			_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 then
		begin
 disp_type_s = p 		end
	when 17 then
		begin
 content_disposition.disposition_type = data[disp_type_s..(p-1)].downcase 		end
	when 2 then
		begin
 param_attr_s = p 		end
	when 4 then
		begin
 param_attr = data[param_attr_s..(p-1)] 		end
	when 7 then
		begin
 qstr_s = p 		end
	when 9 then
		begin
 qstr = data[qstr_s..(p-1)] 		end
	when 5 then
		begin
 param_val_s = p 		end
	when 18 then
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
end
	when 10 then
		begin
 		end
	when 13 then
		begin
 		end
	when 3 then
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
	when 16 then
		begin
 	begin
		top -= 1
		cs = stack[top]
		_goto_level = _again
		next
	end
 		end
	when 8 then
		begin
 qstr_s = p 		end
		begin
 qstr = data[qstr_s..(p-1)] 		end
	when 6 then
		begin
 param_val_s = p 		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
	when 22 then
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
	when 12 then
		begin
 		end
		begin
 param_attr_s = p 		end
	when 20 then
		begin
 		end
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
end
	when 11 then
		begin
 		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
	when 14 then
		begin
 		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
	when 15 then
		begin
 		end
		begin
 	begin
		top -= 1
		cs = stack[top]
		_goto_level = _again
		next
	end
 		end
	when 19 then
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
end
	when 21 then
		begin
 		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 21
		_goto_level = _again
		next
	end
 		end
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
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 17 then
		begin
 content_disposition.disposition_type = data[disp_type_s..(p-1)].downcase 		end
	when 18 then
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
end
	when 10 then
		begin
 		end
	when 20 then
		begin
 		end
		begin

if param_attr.nil?
  raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
end

# Use quoted string value if one exists, otherwise use parameter value
value = qstr || data[param_val_s..(p-1)]

content_disposition.parameters << { param_attr => value }
param_attr = nil
qstr = nil
end
	  end
	end

	end
	if _goto_level <= _out
		break
	end
end
	end


  if p != eof || cs < 26
    raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "Only able to parse up to #{data[0..p]}")
  end

  content_disposition
end