示例#1
0
static void
collect_tags_mapper (struct taginfo *tag, void *arg)
{
  struct map_context *ctx = (struct map_context *)arg;

  /* Find the tag in our table of tags.  This must not fail because
     map_html_tags only returns tags found in interesting_tags.

     I've changed this for now, I'm passing NULL as interesting_tags
     to map_html_tags.  This way we can check all tags for a style
     attribute.
  */
  struct known_tag *t = hash_table_get (interesting_tags, tag->name);

  if (t != NULL)
    t->handler (t->tagid, tag, ctx);

  check_style_attr (tag, ctx);

  if (tag->end_tag_p && (0 == strcasecmp (tag->name, "style"))
      && tag->contents_begin && tag->contents_end
      && tag->contents_begin <= tag->contents_end)
  {
    /* parse contents */
    get_urls_css (ctx, tag->contents_begin - ctx->text,
                  tag->contents_end - tag->contents_begin);
  }
}
示例#2
0
文件: css-url.c 项目: DonCN/haiku
struct urlpos *
get_urls_css_file (const char *file, const char *url)
{
  struct file_memory *fm;
  struct map_context ctx;

  /* Load the file. */
  fm = read_file (file);
  if (!fm)
    {
      logprintf (LOG_NOTQUIET, "%s: %s\n", file, strerror (errno));
      return NULL;
    }
  DEBUGP (("Loaded %s (size %s).\n", file, number_to_static_string (fm->length)));

  ctx.text = fm->content;
  ctx.head = ctx.tail = NULL;
  ctx.base = NULL;
  ctx.parent_base = url ? url : opt.base_href;
  ctx.document_file = file;
  ctx.nofollow = 0;

  get_urls_css (&ctx, 0, fm->length);
  read_file_free (fm);
  return ctx.head;
}
示例#3
0
static void
check_style_attr (struct taginfo *tag, struct map_context *ctx)
{
  int attrind;
  int raw_start;
  int raw_len;
  char *style = find_attr (tag, "style", &attrind);
  if (!style)
    return;

  /* raw pos and raw size include the quotes, skip them when they are
     present.  */
  raw_start = ATTR_POS (tag, attrind, ctx);
  raw_len  = ATTR_SIZE (tag, attrind);
  if( *(char *)(ctx->text + raw_start) == '\''
      || *(char *)(ctx->text + raw_start) == '"')
    {
      raw_start += 1;
      raw_len -= 2;
    }

  if(raw_len <= 0)
       return;

  get_urls_css (ctx, raw_start, raw_len);
}