ad_parse_html_attributes_upvar (private)

 ad_parse_html_attributes_upvar [ -attribute_array attribute_array ] \
    html_varname pos_varname

Defined in packages/acs-tcl/tcl/text-html-procs.tcl

Parse attributes in an HTML fragment and return them as a list of lists.

Each element of that list is either a single element, if the attribute had no value, or a two-tuple, with the first element being the name of the attribute and the second being the value. The attribute names are all converted to lowercase.

If you don't really care what happens when the same attribute is present twice, you can also use the attribute_array argument, and the attributes will be set there. For attributes without any value, we'll use the empty string.

Example:

set html {<tag foo = bar baz greble="&quot;hello you sucker&quot;" foo='blah' Heres = '  something for   you to = "consider" '>}
    set pos 5 ; # the 'f' in the first 'foo'

    set attribute_list [ad_parse_html_attributes_upvar -attribute_array attribute_array html pos]
attribute_list will contain the following:
{foo bar} baz {greble {"hello you sucker"}} {foo blah} {heres {  something for   you to = "consider" }}
attribute_array will contain:
attribute_array(foo)='blah'
    attribute_array(greble)='"hello you sucker"'
    attribute_array(baz)=''
    attribute_array(heres)='  something for   you to = "consider" '

Won't alter the string passed in .. promise! We will modify pos_var. Pos_var should point to the first character inside the tag, after the tag name (we don't care if you let if there's some whitespace before the first attribute)

Switches:
-attribute_array
(optional)
This is an alternate way of returning the attributes, if you don't care about what happens when the same attribute name is defined twice.
Parameters:
html_varname - the name of the variable holding the HTML fragment. We promise that we won't change the contents of this variable.
pos_varname - the name of the variable holding the position within the html_varname string from which we should start. This should point to a character inside the tag, just after the tag name, and before the first attribute. Note that we will modify this variable. When this proc is done, this variable will point to the tag-closing >. Example: if the tag is <img src="foo">, pos_varname should point to either the space between img and src, or the s in src.
Returns:
A list of list holding the attribute names and values. Each element of that list is either a single element, if the attribute had no value, or a two-tuple, with the first element being the name of the attribute and the second being the value. The attribute names are all converted to lowercase.
Author:
Lars Pind <lars@pinds.com>
Created:
November 10, 2000

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_html_security_check_forbidden_protolcols ad_html_security_check_forbidden_protolcols (test acs-tcl) ad_parse_html_attributes_upvar ad_parse_html_attributes_upvar test_ad_html_security_check_forbidden_protolcols->ad_parse_html_attributes_upvar test_ad_html_security_check_href_allowed ad_html_security_check_href_allowed (test acs-tcl) test_ad_html_security_check_href_allowed->ad_parse_html_attributes_upvar test_ad_html_text_convert ad_html_text_convert (test acs-tcl) test_ad_html_text_convert->ad_parse_html_attributes_upvar test_ad_html_to_text_anchor ad_html_to_text_anchor (test acs-tcl) test_ad_html_to_text_anchor->ad_parse_html_attributes_upvar test_ad_html_to_text_bold ad_html_to_text_bold (test acs-tcl) test_ad_html_to_text_bold->ad_parse_html_attributes_upvar util_expand_entities_ie_style util_expand_entities_ie_style (public) ad_parse_html_attributes_upvar->util_expand_entities_ie_style ad_parse_html_attributes ad_parse_html_attributes (public) ad_parse_html_attributes->ad_parse_html_attributes_upvar

Testcases:
ad_html_to_text_bold, ad_html_to_text_anchor, ad_html_to_text_image, ad_html_security_check_href_allowed, ad_html_security_check_forbidden_protolcols, ad_html_text_convert
[ show source ]
Show another procedure: