Commit d569186a authored by rinpatch's avatar rinpatch

fix returning attribute name as value when the latter is empty

parent 151d6d4a
Pipeline #22699 passed with stage
in 1 minute and 52 seconds
......@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [1.0.2] - 2020-02-10
### Fixed
- Incorrect behavior when parsing empty attribute values. Instead of an empty string the attribute name was returned.
## [1.0.1] - 2019-12-11
### Added
- `:fast_html.decode_fragment`
......
......@@ -398,10 +398,7 @@ static void prepare_node_attrs(ei_x_buff * response, myhtml_tree_node_t * node)
ei_x_encode_tuple_header (response, 2);
ei_x_encode_binary (response, attr_name, attr_name_len);
if (attr_value_len)
ei_x_encode_binary (response, attr_value, attr_value_len);
else
ei_x_encode_binary (response, attr_name, attr_name_len);
ei_x_encode_binary (response, attr_value, attr_value_len);
}
ei_x_encode_empty_list (response);
......
......@@ -4,7 +4,7 @@ defmodule FastHtml.Mixfile do
def project do
[
app: :fast_html,
version: "1.0.1",
version: "1.0.2",
elixir: "~> 1.5",
deps: deps(),
package: package(),
......
......@@ -88,7 +88,7 @@ defmodule :fast_html_test do
{:head, [], []},
{:body, [],
[
{:button, [{"disabled", "disabled"}, {"class", "foo garble"}], []}
{:button, [{"disabled", ""}, {"class", "foo garble"}], []}
]}
]}
]} =
......@@ -119,7 +119,7 @@ defmodule :fast_html_test do
{:head, [], []},
{:body, [],
[
{:a, [{"<", "<"}], [" asdf"]}
{:a, [{"<", ""}], [" asdf"]}
]}
]}
]} = :fast_html.decode(~s'<a <> asdf', format: [:html_atoms])
......@@ -175,4 +175,9 @@ defmodule :fast_html_test do
assert {:ok, [{:comment, " a comment "}, {"html", [], [{"head", [], []}, {"body", [], []}]}]} ==
:fast_html.decode("<!-- a comment --> <html> </html>")
end
test "doesn't return attribute name in attribute value when the latter is empty" do
assert :fast_html.decode_fragment("<meta content=\"\"/>") ==
{:ok, [{"html", [], [{"meta", [{"content", ""}], []}]}]}
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment