[gs-bugs] [Bug 691559] New: bad xml output

bugzilla-daemon at ghostscript.com bugzilla-daemon at ghostscript.com
Mon Aug 16 21:50:24 UTC 2010


http://bugs.ghostscript.com/show_bug.cgi?id=691559

           Summary: bad xml output
           Product: MuPDF
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P4
         Component: apps
        AssignedTo: tor.andersson at artifex.com
        ReportedBy: mupdfxmltracebug at mailinator.com
         QAContact: gs-bugs at ghostscript.com
   Estimated Hours: 0.0


pdfdraw -x filename.pdf
The xml trace output does not escape the xml strings, producing invalid xml.

I fixed mine by modifying mupfd\fitz\res_text.c  (although there is another
place which has the error, but it didn't effect my usage)

fz_debugtext prints the character with 
printf("<g ucs=\"%c\" ..., test->els[i].ucs, ...

I replaced that with 
printf("<g ucs=\"%s\" ..., GetXmlCharacter( test->els[i].ucs), ...

and this really fast utility function:

const char * GetXmlCharacter (char ucs){
    static const char * strAmpersand  = "&amp;";
    static const char * strApostrophe = "&apos;";
    static const char * strGreater    = "&gt;";
    static const char * strLess       = "&lt;";
    static const char * strQuote      = "&quot;";
    static char unescaped [2];
    int bFirst = 1;
    if (bFirst){
        bFirst = 0;
        memset(unescaped, '\0', sizeof(unescaped));
    }

    switch (ucs){
        case '&':
            return strAmpersand;
        case '\'':
            return strApostrophe;
        case '>':
            return strGreater;
        case '<':
            return strLess;
        case '\"':
            return strQuote;
        default:
            {
                unescaped[0] = ucs;
                return unescaped;
            }
    }
}

-- 
Configure bugmail: http://bugs.ghostscript.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the gs-bugs mailing list