pml-lang / pml-companion

Java source code of the 'PML Companion (PMLC)'
https://www.pml-lang.dev
GNU General Public License v2.0
22 stars 1 forks source link

HTML Attributes Ignored on Images #90

Closed tajmone closed 1 year ago

tajmone commented 1 year ago

I noticed that with PMLC 3.1.0 I'm failing to render HTML Attributes for images alt or title text:

[image source="./apple.png" html_alt="Some text"]
[image source="./apple.png" html_title="Some text"]

both statements will just produce the following HTML snippet:

<figure style="text-align: left">
    <img class="pml-image" src="./apple.png">
</figure>

As far as I can remember, both used to work fine in my previous tests with PML 2.x, and the html_alt is even mentioned in the PML User Manual examples.

I haven't had a chance to test whether this is affecting just images or other elements too, but it definitely looks like a bug that crept in with the latest updates (either 3.0 or 3.1.0).

pml-lang commented 1 year ago

The underlying bug is that HTML attributes (html_xxx) for media nodes (image, audio, video) are ignored in the HTML renderer.

The bug is now fixed in the develop branch, and the fix will be included in the next public version.

Thanks for reporting this bug.

tajmone commented 1 year ago

Fuzz Testing?

Since the PML syntax is quite complex in terms of all the possible combinations of nodes and attributes, types of attributes values, as well node contexts, it's going to be very hard to be able to manually cover all possible test conditions (both valid and invalid, to test successes and proper error handling).

Probably the best solution would be to rely on fuzz testing instead.

I believe there are various Java libraries for fuzz testing, either native or ported (e.g. JQF). Although it would require investing energy on its initial setup, I believe it's worth the costs since it will therefrom grant solid test coverage for all the various combinations between nodes, and between nodes and their attributes.

If I've understood correctly, most fuzzing libraries require you define a rule-based driver, via some sort of grammar describing a template for the possible combinations in the generated input sources fed to to test unit.

With syntaxes like PML, it's just too hard to manually cover all edge cases testing, and bugs tend to get by unnoticed for a long time.

pml-lang commented 1 year ago

Interesting idea! Thanks for the links. I'll have a look at them.

pml-lang commented 1 year ago

Fixed in version 4.0.0