# frozen_string_literal: true #-- # gravaty # rubocop:disable Style/AsciiComments # © 2013 Peter R. Marreck # rubocop:enable Style/AsciiComments # # This file is part of gravaty. # # gravaty is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # gravaty is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with gravaty. If not, see . # # SPDX-FileCopyrightText: 2013 Peter R. Marreck # # SPDX-License-Identifier: BSD-3-Clause #++ module Gravaty module Utils # This module is a simple wrapper container for Peter R. Marreck's gist. # # Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com] # rubocop:disable Style/AsciiComments # Copyright:: Copyleft (©) 2013, Peter R. Marreck # rubocop:enable Style/AsciiComments # License:: This work is released under the BSD 3-Clause License # http://choosealicense.com/licenses/bsd-3-clause/ module Rfc5322 # Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com] # rubocop:disable Style/AsciiComments # Copyright:: Copyleft (©) 2013, Peter R. Marreck # rubocop:enable Style/AsciiComments # License:: This work is released under the BSD 3-Clause License # http://choosealicense.com/licenses/bsd-3-clause/ # RFC 5322 Email Validation Regex in Ruby # This work is released under the BSD 3-Clause License # http://choosealicense.com/licenses/bsd-3-clause/ # rubocop:disable Style/AsciiComments # Copyleft (©) 2013, Peter R. Marreck # rubocop:enable Style/AsciiComments # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # Neither the name of the {organization} nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EMAIL = %r{ (? (?> \g @ \g ) ){0} (? (?> \g | \g | \g ) ){0} (? (?> \g | \g | \g ) ){0} (? (?> \g? \[ (?: \g? \g )* \g? \] \g? ) ){0} (? (?> [\x21-\x5a] | [\x5e-\x7e] | \g ) ){0} (? (?> \\ (?: \g | \g ) | \g ) ){0} (? (?> \g? \g \g? ) ){0} (? (?> \g (?: \. \g )* ) ){0} (? (?> [a-zA-Z0-9!\#\$%&'*\+/\=\?\^_`{\|}~\-]+ ) ){0} (? (?> \g? \g \g? ) ){0} (? (?> \g | \g ) ){0} (? (?> \g? " (?: \g? \g )* \g? " \g? ) ){0} (? (?> \g | \g ) ){0} (? (?> \x21 | [\x23-\x5b] | [\x5d-\x7e] | \g ) ){0} # comments and whitespace (? (?> (?: \g* \r\n )? \g+ | \g ) ){0} (? (?> (?: \g? \g )+ \g? | \g ) ){0} (? (?> \( (?: \g? \g )* \g? \) ) ){0} (? (?>\g | \g | \g ) ){0} (? (?> [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | \g ) ){0} # obsolete tokens (? (?> \g (?: \. \g )* ) ){0} (? (?> \g (?: \. \g )* ) ){0} (? (?> \g | \g ) ){0} (? (?> \\ (?: \x00 | \g | \n | \r ) ) ){0} (? (?> \g+ (?: \r\n \g+ )* ) ){0} (? (?> \g ) ){0} (? (?> \g ) ){0} (? (?> [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ){0} # character class definitions (? (?> [\x21-\x7E] ) ){0} (? [ \t] ){0} \g }uix end end end