
    xh\
                     .    d dl mZ  G d de          ZdS )   )ApiKeyIncludedExceptionc                   *    e Zd ZdZdZddZd Zd ZdS )ValidateApiKeyz;Validates content to ensure SendGrid API key is not presentNTc                    ddl }t                      | _        |2|D ]/}| j                            |                    |                     0|r1d}| j                            |                    |                     dS dS )zCreate an API key validator

            :param regex_strings: list of regex strings
            :type regex_strings: list(str)
            :param use_default: Whether or not to include default regex
            :type use_default: bool
            NzSG\.[0-9a-zA-Z]+\.[0-9a-zA-Z]+)resetregexesaddcompile)selfregex_stringsuse_defaultr   regex_stringdefault_regex_strings         S/var/www/html/what/lib/python3.11/site-packages/sendgrid/helpers/mail/validators.py__init__zValidateApiKey.__init__	   s     				uu $ - ; ;  L!9!9:::: 	?#D LRZZ(<==>>>>>	? 	?    c                    t          |t                    r|                     |           dS t          |t                    r|                    dt                                }|D ]r}|l|                    d          dk    s(t          |                    d          t                    r+|                    dd          }|                     |           qdS dS )a  With the JSON dict that will be sent to SendGrid's API,
            check the content for SendGrid API keys - throw exception if found.

           :param request_body: The JSON dict that will be sent to SendGrid's
                                API.
           :type request_body: JSON serializable structure
           :raise ApiKeyIncludedException: If any content in request_body
                                           matches regex
        contentNtypez	text/htmlvalue )
isinstancestrvalidate_message_textdictgetlist)r   request_bodycontentsr   message_texts        r   validate_message_dictz$ValidateApiKey.validate_message_dict   s     lC(( 	A&&|44444 d++ 		A#''	466::H# A A&F++{::&w{{7';';SAA ;'.{{7B'?'?22<@@@		A 		AA Ar   c                     t          |t                    r-| j        D ]'}|                    |          t	                      &dS dS )af  With a message string, check to see if it contains a SendGrid API Key
            If a key is found, throw an exception

           :param message_string: message that will be sent
           :type message_string: string
           :raises ApiKeyIncludedException: If message_string matches a regex
                                            string
        N)r   r   r
   matchr   )r   message_stringregexs      r   r   z$ValidateApiKey.validate_message_text9   s^     nc** 	4 4 4;;~..:1333 ;	4 	44 4r   )NT)__name__
__module____qualname____doc__r
   r   r#   r    r   r   r   r      sT        EEG? ? ? ?*A A A64 4 4 4 4r   r   N)
exceptionsr   objectr   r,   r   r   <module>r/      sU    / / / / / /A4 A4 A4 A4 A4V A4 A4 A4 A4 A4r   