Roxen.git / server / etc / modules / RXML.pmod / utils.pmod

version» Context lines:

Roxen.git/server/etc/modules/RXML.pmod/utils.pmod:1:   //! Things that belong elsewhere but can't lie there for various silly   //! reasons. Everything here is considered internal and not part of   //! the RXML.pmod API.   //!   //! E.g. one reason is to avoid circular references in the parser   //! objects when the callbacks are defined in them.   //!   //! Created 2000-01-21 by Martin Stjernholm   //! - //! $Id: utils.pmod,v 1.14 2000/09/05 21:01:00 mast Exp $ + //! $Id: utils.pmod,v 1.15 2001/03/01 03:12:57 mast Exp $         array return_zero (mixed... ignored) {return 0;}   array return_empty_array (mixed... ignored) {return ({});}      int(1..1)|string|array free_text_error (Parser.HTML p, string str)   {    sscanf (str, "%[ \t\n\r]", string ws);    if (str != ws) {    sscanf (reverse (str), "%*[ \t\n\r]%s", str);
Roxen.git/server/etc/modules/RXML.pmod/utils.pmod:68:    string entity = p->tag_name();    if (sizeof (entity)) {    if (entity[0] != '#')    return p->handle_var (entity,    p->html_context() == "splice_arg" ?    // No quoting of splice args. FIXME: Add    // some sort of safeguard against splicing    // in things like "nice><evil stuff='...'"?    RXML.t_text :    p->type); -  if (p->type->encoding_type != "xml") { -  // Don't decode any normal entities if we're outputting xml-like stuff. -  if (!p->type->free_text) return ({}); -  string out; -  if ((<"#x", "#X">)[entity[..1]]) { -  if (sscanf (entity, "%*2s%x%*c", int c) == 2) out = sprintf ("%c", c); +  if (!p->type->entity_syntax) { +  // Don't decode normal entities if we're outputting xml-like stuff. +  if (!p->type->free_text) +  RXML.parse_error ("Unknown entity &%s; not allowed in this context.\n", entity); +  if (sscanf (entity, +  (<"#x", "#X">)[entity[..1]] ? "%*2s%x%*c" : "%*c%d%*c", +  int char) == 2) +  catch {return ({(string) ({char})});}; +  // Lax error handling: Just let it through if it can't be +  // converted. Not really good, though.    } -  else -  if (sscanf (entity, "%*c%d%*c", int c) == 2) out = sprintf ("%c", c); -  return out && ({out}); +     } -  } +     if (!p->type->free_text)    RXML.parse_error ("Unknown entity &%s; not allowed in this context.\n", entity);    return 0;   }      int(1..1)|string|array p_xml_compat_entity_cb (Parser.HTML p, string str)   {    string entity = p->tag_name();    if (sizeof (entity) && entity[0] != '#')    return p->handle_var (entity,    p->html_context() == "splice_arg" ?    // No quoting of splice args. FIXME: Add    // some sort of safeguard against splicing    // in things like "nice><evil stuff='...'"?    RXML.t_text :    p->type);    if (!p->type->free_text)    RXML.parse_error ("Unknown entity &%s; not allowed in this context.\n", entity);    return 0;   }