Attachment "htmlparse.patch" to
ticket [2941841fff]
added by
dvrsn
2012-03-14 23:56:18.
Index: htmlparse.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/htmlparse/htmlparse.tcl,v
retrieving revision 1.28
diff -c -3 -r1.28 htmlparse.tcl
*** htmlparse.tcl 10 Feb 2009 20:37:22 -0000 1.28
--- htmlparse.tcl 14 Mar 2012 16:55:41 -0000
***************
*** 331,338 ****
# Convert the HTML string into a script.
! set sub "\}\n$cmd {\\1} {} {\\2} \{\}\n$cmd {\\1} {/} {} \{"
! regsub -all -- {<([^\s>]+)\s*([^>]*)/>} $html $sub html
set sub "\}\n$cmd {\\2} {\\1} {\\3} \{"
regsub -all -- {<(/?)([^\s>]+)\s*([^>]*)>} $html $sub html
--- 331,337 ----
# Convert the HTML string into a script.
! regsub -all -- {<([^\s>]+)\s*([^>]*)/>} $html {<\1 \2></\1>} html
set sub "\}\n$cmd {\\2} {\\1} {\\3} \{"
regsub -all -- {<(/?)([^\s>]+)\s*([^>]*)>} $html $sub html
Index: htmlparse.test
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/htmlparse/htmlparse.test,v
retrieving revision 1.26
diff -c -3 -r1.26 htmlparse.test
*** htmlparse.test 10 Feb 2009 20:37:22 -0000 1.26
--- htmlparse.test 14 Mar 2012 16:55:41 -0000
***************
*** 504,509 ****
--- 504,530 ----
[list b / {} {}] \
[list html / {} {}] ]
+ test htmlparse-10.0 {bad html, raising error} {
+ set tags [list]
+ htmlparse::parse -cmd cb -vroot html "<a<a/>>"
+ set tags
+ } [list \
+ [list html {} {} {}] \
+ [list a<a {} {} {}] \
+ [list a<a / {} {>}] \
+ [list html / {} {}] ]
+
+ test htmlparse-10.1 {bad html, varying argument counts} {
+ set tags [list]
+ htmlparse::parse -cmd cb -vroot html {<a b="<a"/><a>}
+ set tags
+ } [list \
+ [list html {} {} {}] \
+ [list a {} {b="<a"} {}] \
+ [list a / {} {}] \
+ [list a {} {} {}] \
+ [list html / {} {}] ]
+
# -------------------------------------------------------------------------
# In this section we run all the tests depending on a struct::tree,
# and thus have to test all the available implementations.