Skip to content

Conversation

@edrichhans
Copy link
Contributor

@edrichhans edrichhans commented Apr 1, 2024

Resolves #92

The problem

  • There is a bug in the algorithm that processes the value of the attribute when it has reached an end quote
  • If it has detected an end quote, it will automatically save the value of str.slice(attrObj.valueStarts, i) into attrObj.value
  • However, attrObj.valueStarts may never have been defined if the attribute is an empty string ""
  • Therefore, the value that gets saved is str.slice(undefined, i), which will is essentially str.slice(0, i). This saves the substring of str from the very start up to i

Solution

  • Handle this case specifically, and reset the attrObj and quotes if the strings are empty

Screenshot of the failing test before the fix:

image

@edrichhans
Copy link
Contributor Author

edrichhans commented Apr 1, 2024

Hey @revelt, I have opened a PR that resolves an issue that I experienced today. I can show more proof of the bug when I run the script in DEV mode, given the following input:

Text <div class="" id="3" >here</div> and some more <article>text</article>.

The following data gets saved into the attrObj.value
image

Hopefully this PR can be merged. Thanks!

@revelt revelt merged commit 16debf9 into codsen:main Apr 4, 2024
@revelt
Copy link
Member

revelt commented Apr 4, 2024

@edrichhans Good job! The new version 13.4.8 is released, try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[string-strip-html] dumpLinkHrefsNearby with empty links causes output to contain the html partially

2 participants