anaskhan96 / soup

Web Scraper in Go, similar to BeautifulSoup
MIT License
2.18k stars 168 forks source link

Fix crash in FullText() recursion if one ElementNode has no children (not even TextNode) #47

Closed Enrico204 closed 4 years ago

Enrico204 commented 4 years ago

When calling FullText() in an ElementNode which as one ElementNode children with no other nodes inside (not even TextNode, which seems strange but it happens), the recursive function should not continue trying to traverse the first child, as it's nil. This pull request handles that case.

ghostlandr commented 4 years ago

Can you try to add a test for this case?

Enrico204 commented 4 years ago

Sorry, I just realized that the crash happened before commit 1d82e8a93a8395bc2155809f809d831184583120 (I was using version 1.1.1). The 1.2 version fixed already this crash :-)