Menu

#5 get_attribute fails if tag has letters from attribute

open
nobody
None
5
2009-02-28
2009-02-28
B.T.
No

Although I'm using your library for non standard tag parsing, I noticed something:

HTML::get_attribute will fail if the tag string has letters from attr in it.
A simple fix is to search for the first space before trying to find the attribute. Patch attached.

I can foresee other instances though where the attribute being looked for might be a substring of another attribute name. A find for [space]attribute[equals] might be better and save work. Patch attached.

Discussion

  • B.T.

    B.T. - 2009-02-28

    patches

     
  • B.T.

    B.T. - 2009-02-28

    2nd variation

     
  • B.T.

    B.T. - 2009-02-28

    let me know if you see a reason why either of those would be bad- eg specification somewhere, or if you decide to commit them.

    Thanks for your great work!

     
  • Davi de Castro Reis

    I am not sure I understand the patch. Can you add a concrete case where the existing code fails?

     
  • B.T.

    B.T. - 2010-04-20

    It has been quite some time, but I seem to recall it being a situation where since you're only moving forward by one character after finding an attribute, it would catch up on multiple hits within the same find given certain strings.

     
  • B.T.

    B.T. - 2010-04-20

    It has just been so long- there could certainly be problems with the patch-- I don't even remember what function that was in! :)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.