appstream-glib icon indicating copy to clipboard operation
appstream-glib copied to clipboard

Validation of `<em>` and `<code>` inside `<li>` elements fails

Open uklotzde opened this issue 4 years ago • 6 comments

According to the spec both <em> and <code> elements can be used in <li> elements in descriptions:

Within paragraphs and list items, emphasis (em) and inline code (code) text styles are supported.

Unfortunately, validation fails with appstream-util 0.7.18 (Fedora 34):

appstream-util validate-relax --nonet res/linux/org.mixxx.Mixxx.metainfo.xml 
res/linux/org.mixxx.Mixxx.metainfo.xml: failed to parse res/linux/org.mixxx.Mixxx.metainfo.xml: Error on line 236 char 5: <li> already set 'It is no longer necessary to manually copy the udev rule file in packaging scripts. Now pkg-config is used to determine the udevdir used to install the rules file in the CMake install step when CMAKE_INSTALL_PREFIX is' and tried to replace with '
   or
   '

Example: org.mixxx.Mixxx.metainfo.xml

Validation with appstreamcli succeeds:

appstreamcli validate --no-net res/linux/org.mixxx.Mixxx.metainfo.xml 
I: org.mixxx.Mixxx:~: content-rating-missing

Validation was successful: infos: 1, pedantic: 1

uklotzde avatar Sep 20 '21 19:09 uklotzde

I think using appstreamcli validate is probably the right thing to use these days.

hughsie avatar Sep 21 '21 10:09 hughsie

Thanks for the confirmation. We already switched to appstreamcli as a workaround and we could stick with it if recommended.

uklotzde avatar Sep 21 '21 13:09 uklotzde

I am running into this bug using flatpak-builder:

Rewriting contents of org.mixxx.Mixxx.desktop
Running appstream-compose
Processing application org.mixxx.Mixxx
Error loading AppData file: failed to parse /app/share/appdata/org.mixxx.Mixxx.appdata.xml: Error on line 265 char 5: <li> already set 'It is no longer necessary to manually copy the udev rule file in packaging scripts. Now pkg-config is used to determine the udevdir used to install the rules file in the CMake install step when CMAKE_INSTALL_PREFIX is' and tried to replace with '
   or
   '
Error: ERROR: appstream-compose failed: Child process exited with code 1

Be-ing avatar Sep 30 '21 22:09 Be-ing

Ugly hack around this in the Flatpak manifest:

    post-install:
      - sed -i 's/<code>//g' ${FLATPAK_DEST}/share/metainfo/org.mixxx.Mixxx.metainfo.xml
      - sed -i 's/<\/code>//g' ${FLATPAK_DEST}/share/metainfo/org.mixxx.Mixxx.metainfo.xml

Be-ing avatar Sep 30 '21 23:09 Be-ing

In the long run https://github.com/flatpak/flatpak/pull/4426 will add support for that in some form, unless appstream-glib implements dedicated support. The only immediate fix I can see though is your sed hack :-/

ximion avatar Oct 01 '21 14:10 ximion

I have the same problem with <em> and <code> in <description>. This fails to parse:

<description>
    <p>foo <em>bar</em> <code>baz</code> qux</p>
</description>
$ appstream-util validate-relax fail.appdata.xml 
failed to parse fail.appdata.xml: Error on line 7 char 46: <p> already set 'foo' and tried to replace with ' qux'

This is with libappstream-glib-0.7.18-3.fc35.x86_64.

Because of this, I can't have markup in package description on Flathub.

kparal avatar Jan 10 '22 11:01 kparal