Skip to content

Commit

Permalink
remove support for non standard entity replacements.
Browse files Browse the repository at this point in the history
This was disabled in d47e364 August 29, 2005.
  • Loading branch information
tsteven4 committed Nov 28, 2021
1 parent dd56f42 commit 2341445
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <QtGlobal> // for qAsConst, QAddConst<>::Type, qPrintable

#include "defs.h"
#include "cet.h" // for cet_utf8_to_ucs4
#include "src/core/datetime.h" // for DateTime
#include "src/core/logging.h" // for Warning
#include "src/core/xmltag.h" // for xml_tag, xml_attribute, xml_findfirst, xml_findnext
Expand Down Expand Up @@ -1524,16 +1523,13 @@ static
char*
entitize(const char* str, bool is_html)
{
int ecount;
int nsecount;
char* p;
char* tmp;
char* xstr;

int bytes = 0;
int value = 0;
entity_types* ep = stdentities;
int elen = ecount = nsecount = 0;
int elen = 0;
int ecount = 0;

/* figure # of entity replacements and additional size. */
while (ep->text) {
Expand All @@ -1546,29 +1542,10 @@ entitize(const char* str, bool is_html)
ep++;
}

/* figure the same for other than standard entities (i.e. anything
* that isn't in the range U+0000 to U+007F */

#if 0
for (cp = str; *cp; cp++) {
if (*cp & 0x80) {
cet_utf8_to_ucs4(cp, &bytes, &value);
cp += bytes-1;
elen += sprintf(tmpsub, "&#x%x;", value) - bytes;
nsecount++;
}
}
#endif

/* enough space for the whole string plus entity replacements, if any */
tmp = (char*) xcalloc((strlen(str) + elen + 1), 1);
strcpy(tmp, str);

/* no entity replacements */
if (ecount == 0 && nsecount == 0) {
return (tmp);
}

if (ecount != 0) {
for (ep = stdentities; ep->text; ep++) {
p = tmp;
Expand All @@ -1590,27 +1567,6 @@ entitize(const char* str, bool is_html)
}
}

if (nsecount != 0) {
p = tmp;
while (*p) {
if (*p & 0x80) {
cet_utf8_to_ucs4(p, &bytes, &value);
if (p[bytes]) {
xstr = xstrdup(p + bytes);
} else {
xstr = nullptr;
}
sprintf(p, "&#x%x;", value);
p = p+strlen(p);
if (xstr) {
strcpy(p, xstr);
xfree(xstr);
}
} else {
p++;
}
}
}
return (tmp);
}

Expand Down

0 comments on commit 2341445

Please sign in to comment.