Module: Mail::Parsers::EnvelopeFromParser

Extended by:
Mail::ParserTools
Defined in:
lib/mail/parsers/envelope_from_parser.rb

Defined Under Namespace

Classes: EnvelopeFromStruct

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Mail::ParserTools

chars

Class Attribute Details

._eof_actionsObject

Returns the value of attribute _eof_actions


3149
3150
3151
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3149

def _eof_actions
  @_eof_actions
end

._index_offsetsObject

Returns the value of attribute _index_offsets


182
183
184
# File 'lib/mail/parsers/envelope_from_parser.rb', line 182

def _index_offsets
  @_index_offsets
end

._indiciesObject

Returns the value of attribute _indicies


228
229
230
# File 'lib/mail/parsers/envelope_from_parser.rb', line 228

def _indicies
  @_indicies
end

._key_spansObject

Returns the value of attribute _key_spans


136
137
138
# File 'lib/mail/parsers/envelope_from_parser.rb', line 136

def _key_spans
  @_key_spans
end

._trans_actionsObject

Returns the value of attribute _trans_actions


3074
3075
3076
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3074

def _trans_actions
  @_trans_actions
end

._trans_keysObject

Returns the value of attribute _trans_keys


13
14
15
# File 'lib/mail/parsers/envelope_from_parser.rb', line 13

def _trans_keys
  @_trans_keys
end

._trans_targsObject

Returns the value of attribute _trans_targs


2999
3000
3001
# File 'lib/mail/parsers/envelope_from_parser.rb', line 2999

def _trans_targs
  @_trans_targs
end

.en_comment_tailObject

Returns the value of attribute en_comment_tail


3208
3209
3210
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3208

def en_comment_tail
  @en_comment_tail
end

.en_mainObject

Returns the value of attribute en_main


3212
3213
3214
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3212

def en_main
  @en_main
end

.errorObject

Returns the value of attribute error


3203
3204
3205
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3203

def error
  @error
end

.first_finalObject

Returns the value of attribute first_final


3199
3200
3201
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3199

def first_final
  @first_final
end

.startObject

Returns the value of attribute start


3195
3196
3197
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3195

def start
  @start
end

Class Method Details

.parse(data) ⇒ Object


3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
# File 'lib/mail/parsers/envelope_from_parser.rb', line 3216

def self.parse(data)
  data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)

  envelope_from = EnvelopeFromStruct.new
  return envelope_from if Mail::Utilities.blank?(data)

  # Parser state
  address_s = ctime_date_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 3
            begin
              address_s = p
            end
          when 17
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 12
            begin
              ctime_date_s = p
            end
          when 13
            begin
            end
          when 37
            begin
            end
          when 19
            begin
            end
          when 11
            begin
            end
          when 6
            begin
            end
          when 4
            begin
            end
          when 25
            begin
            end
          when 23
            begin
            end
          when 33
            begin
            end
          when 5
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 293
                _goto_level = _again
                next
              end
            end
          when 40
            begin
              begin
                top -= 1
                cs = stack[top]
                _goto_level = _again
                next
              end
            end
          when 1
            begin
              address_s = p
            end
            begin
            end
          when 18
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 16
            begin
            end
            begin
            end
          when 36
            begin
            end
            begin
            end
          when 35
            begin
            end
            begin
            end
          when 15
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 293
                _goto_level = _again
                next
              end
            end
          when 38
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 293
                _goto_level = _again
                next
              end
            end
          when 39
            begin
            end
            begin
              begin
                top -= 1
                cs = stack[top]
                _goto_level = _again
                next
              end
            end
          when 21
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 20
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 293
                _goto_level = _again
                next
              end
            end
          when 10
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 29
            begin
            end
            begin
            end
          when 9
            begin
            end
            begin
            end
          when 8
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 293
                _goto_level = _again
                next
              end
            end
          when 24
            begin
            end
            begin
            end
          when 32
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 2
            begin
              address_s = p
            end
            begin
            end
            begin
              begin
                stack[top] = cs
                top += 1
                cs = 293
                _goto_level = _again
                next
              end
            end
          when 22
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 14
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 31
            begin
            end
            begin
            end
            begin
            end
          when 34
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 28
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 7
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 27
            begin
            end
            begin
            end
            begin
            end
          when 30
            begin
            end
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            end
          when 26
            begin
            end
            begin
            end
            begin
            end
            begin
              envelope_from.address = chars(data, address_s, p - 1).rstrip
            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 41
            begin
              envelope_from.ctime_date = chars(data, ctime_date_s, p - 1)
            end
          when 42
            begin
            end
            begin
              envelope_from.ctime_date = chars(data, ctime_date_s, p - 1)
            end
          end
        end
      end
      if _goto_level <= _out
        break
      end
    end
  end

  if p != eof || cs < 305
    raise Mail::Field::IncompleteParseError.new(Mail::EnvelopeFromElement, data, p)
  end

  envelope_from
end