apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 53082] New: apr_xml_to_text does not properly escape entities ("&")
Date Fri, 13 Apr 2012 22:31:59 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=53082

             Bug #: 53082
           Summary: apr_xml_to_text does not properly escape entities
                    ("&")
           Product: APR
           Version: HEAD
          Platform: PC
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR-util
        AssignedTo: bugs@apr.apache.org
        ReportedBy: Christopher.D.Knight@nasa.gov
    Classification: Unclassified


the apr_xml_to_text (really the write_text) function should re-escape entities
to make valid XML CDATA blocks...For example:

--output of example code--
RESULT:
(40) <tag>test with an & in the middle</tag>

--example code--
#include <apr_pools.h>
#include <apr_xml.h>

int main(int argc, char **argv) {
    apr_xml_parser *parser = NULL; apr_pool_t *pool = NULL; apr_xml_doc *pdoc =
NULL; int namespace_mapping[100];
    char *testxml = "<?xml version=\"1.0\"?>\n<tag>test with an &amp; in the
middle</tag>\n";

    apr_pool_initialize(); apr_pool_create(&pool, NULL);

    parser = apr_xml_parser_create(pool); apr_xml_parser_feed(parser, testxml,
strlen(testxml)); apr_xml_parser_done(parser, &pdoc);
    const char *buf = NULL; apr_size_t buflen = 0;
    apr_xml_to_text(pool, pdoc->root, APR_XML_X2T_FULL, pdoc->namespaces,
namespace_mapping, (const char **)&buf, &buflen);
    printf("RESULT:\n(%ld) %s\n", buflen, buf);

    apr_pool_destroy(pool); apr_pool_terminate();
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message