Skip to content

Commit

Permalink
Fix range escaping in conflict reports involving ranges (conan-io#15222)
Browse files Browse the repository at this point in the history
* Add failing test that should pass after issue is fixed

* Fix range escaping in conflict reports involving ranges
  • Loading branch information
AbrilRBS authored Dec 6, 2023
1 parent acbaf44 commit a6f42bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions conan/cli/formatters/graph/info_graph_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@
// Add error conflict node
nodes.push({
id: "{{ error["type"] }}",
label: "{{ error["context"].require.ref }}",
label: {{ error["context"].require.ref|string|tojson }},
shape: "circle",
font: { color: "white" },
color: "red",
fulllabel: '<h3>{{ error["context"].require.ref }}</h3><p>This node creates a conflict in the dependency graph</p>',
fulllabel: '<h3>' +
{{ error["context"].require.ref|string|tojson }} +
'</h3><p>This node creates a conflict in the dependency graph</p>',
shapeProperties: { borderDashes: [5, 5] }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_user_templates():
assert template_folder in c.stdout


def test_graph_info_html_output():
def test_graph_info_html_error_reporting_output():
tc = TestClient()
tc.save({"lib/conanfile.py": GenConanfile("lib"),
"ui/conanfile.py": GenConanfile("ui", "1.0").with_requirement("lib/1.0"),
Expand Down Expand Up @@ -212,3 +212,17 @@ def test_graph_info_html_output():
# There used to be a few bugs with weird graphs, check for regressions
assert "jinja2.exceptions.UndefinedError" not in tc.out
assert "from: ," not in tc.out


def test_graph_info_html_error_range_quoting():
tc = TestClient()
tc.save({"zlib/conanfile.py": GenConanfile("zlib"),
"libpng/conanfile.py": GenConanfile("libpng", "1.0").with_requirement("zlib/[>=1.0]")})

tc.run("export zlib --version=1.0")
tc.run("export zlib --version=0.1")
tc.run("export libpng")

tc.run("graph info --requires=zlib/0.1 --requires=libpng/1.0 --format=html", assert_error=True)
assert 'zlib/[&gt;=1.0]' not in tc.out
assert r'"zlib/[\u003e=1.0]"' in tc.out

0 comments on commit a6f42bf

Please sign in to comment.