
    qh                     
   S S/r SSKJr  SSKrSSKrSSKrSSKJr  Sr	 " S S\
5      r " S	 S\
5      r\R                  \R                  -  \R                  -  rS
r\R$                  " \\5      rS rS r " S S\5      rS rg)findHTMLMetaMetaNotFound    )
HTMLParserN)YADIS_HEADER_NAMEi @  c                       \ rS rSrSrSrg)	ParseDone   zException to hold the URI that was located when the parse is
finished. If the parse finishes without finding the URI, set it to
None. N__name__
__module____qualname____firstlineno____doc____static_attributes__r
       H/var/www/html/env/lib/python3.13/site-packages/openid/yadis/parsehtml.pyr   r      s    r   r   c                       \ rS rSrSrSrg)r      zWException to hold the content of the page if we did not find
the appropriate <meta> tagr
   Nr   r
   r   r   r   r      s    "r   zO
&

(?: \#x (?P<hex> [a-f0-9]+ )
|   \# (?P<dec> \d+ )
|   (?P<word> \w+ )
)

;c                    U R                   S:X  a  [        U R                  S5      S5      nOuU R                   S:X  a  [        U R                  S5      5      nOJU R                   S:X  d   e[        R                  R
                  R                  U R                  S5      5      nUc  U R                  5       $ [        U5      $ )Nhex   decword)	lastgroupintgrouphtmlentitiesname2codepointgetchr)mo	codepoints     r   substituteMOr%   (   s    	||u,			(	||v%%%MM0044RXXf5EF	xxz9~r   c                 6    [         R                  [        U 5      $ N)ent_resubr%   )ss    r   substituteEntitiesr+   7   s    ::lA&&r   c                   ^   ^  \ rS rSrSrSrSrSrSrSr	U 4S jr
S	 rS
 rS rU 4S jrSrU =r$ )YadisHTMLParser;   a  Parser that finds a meta http-equiv tag in the head of a html
document.

When feeding in data, if the tag is matched or it will never be
found, the parser will raise ParseDone with the uri as the first
attribute.

Parsing state diagram
=====================

Any unlisted input does not affect the state::

            1, 2, 5                       8
           +--------------------------+  +-+
           |                          |  | |
        4  |    3       1, 2, 5, 7    v  | v
    TOP -> HTML -> HEAD ----------> TERMINATED
    | |            ^  |               ^  ^
    | | 3          |  |               |  |
    | +------------+  +-> FOUND ------+  |
    |                  6         8       |
    | 1, 2                               |
    +------------------------------------+

  1. any of </body>, </html>, </head> -> TERMINATE
  2. <body> -> TERMINATE
  3. <head> -> HEAD
  4. <html> -> HTML
  5. <html> -> TERMINATE
  6. <meta http-equiv='X-XRDS-Location'> -> FOUND
  7. <head> -> TERMINATE
  8. Any input -> TERMINATE
r               c                    > [         R                  R                  S::  a  [        [        U ]  SS9  O[        [        U ]  5         U R                  U l        g )Nr0   F)strict)sysversion_infominorsuperr-   __init__TOPphase)self	__class__s    r   r9   YadisHTMLParser.__init__c   sC    ""a' /411?/413XX
r   c                 :    U R                   U l        [        S 5      er'   )
TERMINATEDr;   r   )r<   s    r   
_terminateYadisHTMLParser._terminatem   s    __
or   c                 2    US;   a  U R                  5         g g )N)headbodyr   )rA   )r<   tags     r   handle_endtagYadisHTMLParser.handle_endtagq   s     **OO +r   c                    US:X  a  U R                  5         U R                  U R                  :X  a1  US:X  a  U R                  U l        g US:X  a  U R                  U l        g g U R                  U R                  :X  a0  US:X  a  U R                  U l        g US:X  a  U R                  5         g g U R                  U R                  :X  a  US:X  a}  [        U5      nUR                  SS5      R                  5       nU[        R                  " 5       :X  a8  UR                  S5      n[        U5      nU R                  U l        [        U5      eg US;   a  U R                  5         g g g )	NrE   rD   r   metaz
http-equiv content)rD   r   )rA   r;   r:   HEADHTMLdictr!   lowerr   r+   FOUNDr   )r<   rF   attrsattrs_d
http_equivraw_attr	yadis_locs          r   handle_starttagYadisHTMLParser.handle_starttagw   s-    &=OO::! f}!YY
!YY
  ZZ499$ f}!YY
!  ZZ499$ f}u+$[[r:@@B
!2!8!8!::&{{95H 28 <I!%DJ#I.. ; ((! ) %r   c                    > U R                   U R                  U R                  4;   a  U R                  5         [        [
        U ]  U5      $ r'   )r;   r@   rQ   rA   r8   r-   feed)r<   charsr=   s     r   rZ   YadisHTMLParser.feed   s8    ::$//4::66OO_d077r   )r;   )r   r   r   r   r   r:   rN   rM   rQ   r@   r9   rA   rG   rW   rZ   r   __classcell__)r=   s   @r   r-   r-   ;   sC     B CDDEJ+"Z8 8r   r-   c                 x   [        5       n/ n U R                  [        5      nU(       d  O%UR                  U5         UR	                  U5        MB  SR                  U5      n[        U5      e! [
         aC  nUR                  S   nUc%  UR                  U R                  5       5         SnAM]  Us SnA$ SnAff = f)aW  Look for a meta http-equiv tag with the YADIS header name.

@param stream: Source of the html text
@type stream: Object that implements a read() method that works
    like file.read

@return: The URI from which to fetch the XRDS document
@rtype: str

@raises MetaNotFound: raised with the content that was
    searched as the first parameter.
r   NrK   )	r-   read
CHUNK_SIZEappendrZ   r   argsjoinr   )streamparserchunkschunkwhyurirL   s          r   r   r      s     FF
J'e		KK $ ggfoG
w
  	((1+C{fkkm,
	s#   A, ,
B961B4-B4.B94B9)__all__html.parserr   html.entitiesr   rer5   openid.yadis.constantsr   r`   	Exceptionr   r   
IGNORECASEUNICODEVERBOSEre_flagsent_patcompiler(   r%   r+   r-   r   r
   r   r   <module>rv      s   >
* "  	 
 4 
	 "9 "
 ==2::%

2 
GX	&'n8j n8b# r   