Пример #1
0
/**
 * xmlGetDocEntity:
 * @doc:  the document referencing the entity
 * @name:  the entity name
 *
 * Do an entity lookup in the document entity hash table and
 * returns the corresponding entity, otherwise a lookup is done
 * in the predefined entities too.
 *
 * Returns A pointer to the entity structure or NULL if not found.
 *
 * OOM: never
 */
xmlEntityPtr
xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
    xmlEntityPtr cur;
    xmlEntitiesTablePtr table;

    if (doc != NULL) {
        if ((doc->intSubset != NULL) && (doc->intSubset->entities != NULL)) {
            table = (xmlEntitiesTablePtr) doc->intSubset->entities;
            cur = xmlGetEntityFromTable(table, name);
            if (cur != NULL)
                return(cur);
        }
        if (doc->standalone != 1) {
            if ((doc->extSubset != NULL) &&
                (doc->extSubset->entities != NULL))
            {
                table = (xmlEntitiesTablePtr) doc->extSubset->entities;
                cur = xmlGetEntityFromTable(table, name);
                if (cur != NULL)
                    return(cur);
            }
        }
    }
    return(xmlGetPredefinedEntity(name));
}
xmlEntityPtr igraph_i_graphml_sax_handler_get_entity(void *state0,
						     const xmlChar* name) {
  xmlEntityPtr predef = xmlGetPredefinedEntity(name);
  if (predef != NULL) return predef;
  IGRAPH_WARNING("unknown XML entity found\n");
  return blankEntity;
}
Пример #3
0
static xmlEntityPtr _get_entity(void *ctxt, const xmlChar *name)
{
  static GHashTable *html_entities = NULL;
  xmlEntityPtr entity;
  gchar *contents;

  /* Check if entity is any of the predefined entities such as & */
  entity = xmlGetPredefinedEntity(name);

  if (!entity) {
    /* Some of the RSS "specifications" are vague on whether HTML
       entities are allowed or not, so we will assume that they are,
       and look up HTML entities whenever we encounter them. */

    if (!html_entities)
      html_entities = htmlent_hash_new();

    contents = (gchar *)g_hash_table_lookup(html_entities, name);

    if (contents) {
      /* TODO: Where do we free this memory? */
      entity = (xmlEntityPtr)g_new0(xmlEntity, 1);
      entity->type = XML_ENTITY_DECL;
      entity->name = name;
      entity->orig = contents;
      entity->content = contents;
      entity->length = g_utf8_strlen(contents, -1);
      entity->etype = XML_INTERNAL_PREDEFINED_ENTITY;
    }
  }

  return entity;
}
Пример #4
0
/* TODO: this one needs more thought... */
static xmlEntityPtr pextsGetEntity(void *ctx, const xmlChar *name)
{
  DBG_FUNC_ENTER();
  if (CB_ABSENT(getEntitySAX)) {
    DBG_FUNC_LEAVE();
    return NULL;
  }
  DBG_FUNC_LEAVE();
  return xmlGetPredefinedEntity(name);
  return NULL;
}
Пример #5
0
static xmlEntityPtr
lsm_dom_parser_get_entity (void *user_data, const xmlChar *name)
{
	LsmDomSaxParserState *state = user_data;
	xmlEntity *entity;
	const char *utf8;

	entity = g_hash_table_lookup (state->entities, name);
	if (entity != NULL)
		return entity;

	utf8 = lsm_dom_get_entity ((char *) name);
	if (utf8 != NULL) {
		entity = xmlNewEntity (NULL, name, XML_INTERNAL_GENERAL_ENTITY, NULL, NULL, (xmlChar *) utf8);

		g_hash_table_insert (state->entities, (char *) name, entity);

		return entity;
	}

	return xmlGetPredefinedEntity(name);
}
Пример #6
0
static xmlEntityPtr
_get_entity(void *user, const xmlChar *name)
{
	XML_Parser parser = (XML_Parser) user;
	xmlEntityPtr ret = NULL;

	if (parser->parser->inSubset == 0) {
		ret = xmlGetPredefinedEntity(name);
		if (ret == NULL)
			ret = xmlGetDocEntity(parser->parser->myDoc, name);

		if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) {
			if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
				/* Predefined entities will expand unless no cdata handler is present */
				if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {
					xmlChar *entity;
					int      len;
					
					_build_entity(name, xmlStrlen(name), &entity, &len);
					parser->h_default(parser->user, (const xmlChar *) entity, len);
					xmlFree(entity);
				} else {
					/* expat will not expand internal entities if default handler is present otherwise
					it will expand and pass them to cdata handler */
					if (parser->h_cdata && ret) {
						parser->h_cdata(parser->user, ret->content, xmlStrlen(ret->content));
					}
				}
			} else {
				if (ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
					_external_entity_ref_handler(user, ret->name, ret->etype, ret->SystemID, ret->ExternalID, NULL);
				}
			}
		}
	}

	return ret;
}
Пример #7
0
static xmlEntityPtr
xml_process_entities (void *ctxt, const xmlChar *name)
{
	gchar *path;
	xmlEntityPtr entity;
	xmlEntityPtr found;
	xmlChar *tmp;
	static xmlDocPtr entities = NULL;

	entity = xmlGetPredefinedEntity (name);

	if (!entity) {
		if (!entities) {
			/* loading HTML entities from external DTD file */
			entities = xmlNewDoc (BAD_CAST "1.0");
			path = g_build_filename (g_get_user_data_dir (), PACKAGE, "/dtd/html.ent", NULL);
			xmlCreateIntSubset (entities, BAD_CAST "HTML entities", NULL, BAD_CAST path);
			g_free (path);
			entities->extSubset = xmlParseDTD (entities->intSubset->ExternalID, entities->intSubset->SystemID);
		}

		if (NULL != (found = xmlGetDocEntity (entities, name))) {
			/* returning as faked predefined entity... */
			tmp = xmlStrdup (found->content);
			tmp = BAD_CAST unhtmlize ((gchar*) tmp);	/* arghh ... slow... */
			entity = (xmlEntityPtr) g_new0 (xmlEntity, 1);
			entity->type = XML_ENTITY_DECL;
			entity->name = name;
			entity->orig = NULL;
			entity->content = tmp;
			entity->length = g_utf8_strlen ((gchar*) tmp, -1);
			entity->etype = XML_INTERNAL_PREDEFINED_ENTITY;
		}
	}

	return entity;
}
Пример #8
0
xmlEntityPtr xml_get_entity(void * user_data, const xmlChar *name)
{
  return xmlGetPredefinedEntity(name);
}
Пример #9
0
/* Expand only the standard entities (gt, lt, amp, apos, quot) */
static xmlEntityPtr
entity_callback(Ctxt *ctxt, const xmlChar *name)
{
	return xmlGetPredefinedEntity(name);
}
Пример #10
0
static xmlEntityPtr xmlsubs_GetEntity(void *user_data, const char *name) {
  return xmlGetPredefinedEntity(name);
}
Пример #11
0
static xmlEntityPtr _getEntity (void * /*userData*/, const gchar * name)
{
  return xmlGetPredefinedEntity (name);
}
Пример #12
0
static xmlEntityPtr
libxml2_cb_get_entity(void *user_data, const xmlChar *name)
{

	return (xmlGetPredefinedEntity(name));
}
Пример #13
0
 static xmlEntityPtr GetEntity(void* /*data*/, const xmlChar *name)
 {
   return xmlGetPredefinedEntity(name);
 }
Пример #14
0
static xmlEntityPtr ncXmlGetEntity(void *user_data, const CHAR *name)
{
	return xmlGetPredefinedEntity(name);
}
Пример #15
0
/*ARGSUSED0*/
static xmlEntityPtr myGetEntity(
    void*          user_data,
    const xmlChar* name)
{
    return xmlGetPredefinedEntity(name);
}
Пример #16
0
static xmlEntityPtr
_get_entity(struct type_5_parser_context *ctx, const xmlChar *name)
{
	warn_if(!ctx, "ctx is NULL");
	return xmlGetPredefinedEntity(name);
}