Skip to content

Escape HTML content #53

@krcb197

Description

@krcb197

It is possible to corrupt the generated HTML by including things that look like HTML tags within the name and desc. This is legal in the systemRDL syntax but corrupts the generated HTML.

Consider the following case:

addrmap reg_name_stress {
     reg {name="The register controls the <h1> signal";
        field { name="This field has some <td> controls"; fieldwidth=1; }  field_a;
        field { name="This field has some normal controls"; fieldwidth=1; }  field_b; } reg_h;
};

This will render as follows:

Image

and:

Image

I think the correct behaviour would be to escape the problematic content as it passes through the peakrdl-html. For example

The register controls the <h1> signal

should be converted to

The register controls the &t;h1&gt; signal

This may be better solved in systemrdl-compiler get_html_desc and get_html_name functions rather than being an issue with the peakrdl-html. The markdown syntax defined by systemRDL does not use any of the characters normally escaped in an HTML string therefore I think it might be safe to simply convert as follows:

Character Safe Form (escaped) Comments
& &amp;
< &lt;
> &gt;
\" &quot; Note that SystemRDL has provision to include a " with an \" which requires slightly different treatment compared to normal
' &#39;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions