leizongmin / leizongmin/htmlstream-rust

HTMLTagAttribute does not parse correctly when it reaches a newline

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
23
Forks
0
PR merge metrics
No merged PRs in 30d

Description

While using this crate I have encountered the following problem:

I have an a href tag which is broken up across two lines. When parsed into an HTMLTag, its {:?} output is as follows:

HTMLTag { name: "a", html: "<a href=\n        \"http://example.domain\">", attributes: "href=\n        \"http://example.domain\"", state: Opening }

As you can see, there is a newline and considerable white space between the href= and the URL in question.

When you attr_iter over this tag's html field, the HTMLTagAttribute associated with the href attribute is as follows:

HTMLTagAttribute { name: "href", value: "" }

The value is an empty string, when it should be http://example.domain.

Despite being uncommon, this apparently is valid HTML and should be supported by this crate.

I may take a look and see if I can make a fork & PR tomorrow that will solve this problem.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the attr_iter implementation and HTMLTagAttribute parsing, then reproduce the multiline a href example from the issue. Done means the parsed href attribute has the URL as its value rather than an empty string, while existing attribute parsing remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, rust
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.