createrepo_c icon indicating copy to clipboard operation
createrepo_c copied to clipboard

cr_xml_dump_int() should point to a forbidden character

Open ppisar opened this issue 1 year ago • 2 comments

struct cr_XmlStruct cr_xml_dump_int(cr_Package *pkg, gboolean filelists_ext, GError **err) correctly rejects a package whose metadata cannot be represented in XML:

    if (cr_Package_contains_forbidden_control_chars(pkg)) {
        g_set_error(err, CREATEREPO_C_ERROR, CRE_XMLDATA,
                    "Forbidden control chars found (ASCII values <32 except 9, 10 and 13).");
        return result;
    }

But the callers would like to know where the forbidden character is. Requested in https://github.com/rpm-software-management/createrepo_c/pull/165#issuecomment-1973088771.

Because cr_Package_contains_forbidden_control_chars() and lower functions are in public createrepo_c/xml_dump.h header file and they miss an argument for returning the precise location, a fix will need to add new functions (and wrap the current ones) not to break ABI.

ppisar avatar Mar 01 '24 12:03 ppisar

reference https://github.com/fedora-copr/copr/issues/3163

sergiomb2 avatar Mar 02 '24 16:03 sergiomb2

PR #425 added printing warning messages which pinpoints a package name, RPM tag name and RPM tag value.

This issue is kept open to:

  • Report exact byte offset in the tag values (it's difficult to locate the offending nonprintablecharacters in the output).
  • Store the warnings into an error buffer and let the caller to print it.

ppisar avatar Mar 04 '24 16:03 ppisar