diff options
author | Dom Lachowicz <doml@src.gnome.org> | 2003-01-31 20:02:36 +0000 |
---|---|---|
committer | Dom Lachowicz <doml@src.gnome.org> | 2003-01-31 20:02:36 +0000 |
commit | c1993fd82e335b5a2be881f475db5f0726c0bd94 (patch) | |
tree | 19da4043bf48dbf4a740c64bd5ffbe2dfbe8460a | |
parent | 712013b2ee0c4676abd6807cc6fdc90bf222fafe (diff) | |
download | librsvg-c1993fd82e335b5a2be881f475db5f0726c0bd94.tar.gz |
some hacks to get around some invalid KDE icons
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | rsvg-private.h | 1 | ||||
-rw-r--r-- | rsvg-shapes.c | 90 | ||||
-rw-r--r-- | rsvg.c | 6 |
4 files changed, 47 insertions, 55 deletions
@@ -1,5 +1,10 @@ 2003-01-31 Dom Lachowicz <cinamod@hotmail.com> + * rsvg.c, rsvg-shapes.c, rsvg-private.h: Some hacks to get around some + nasty invalid KDE SVGs Uraeus presented me with. No longer crash. + +2003-01-31 Dom Lachowicz <cinamod@hotmail.com> + * rsvg-styles.c (parse_cssbuffer): Fix some overflows and such. All of the W3 testcases now load, albeit many do so incorrectly. /me hears a giant sucking sound made by CSS2 diff --git a/rsvg-private.h b/rsvg-private.h index ce304bc3..bccb551e 100644 --- a/rsvg-private.h +++ b/rsvg-private.h @@ -55,6 +55,7 @@ struct RsvgHandle { int n_state_max; RsvgDefs *defs; + gboolean in_defs; GHashTable *css_props; /* not a handler stack. each nested handler keeps diff --git a/rsvg-shapes.c b/rsvg-shapes.c index 7bc3867c..30eef3d5 100644 --- a/rsvg-shapes.c +++ b/rsvg-shapes.c @@ -267,6 +267,9 @@ rsvg_start_path (RsvgHandle *ctx, const xmlChar **atts) char *d = NULL; const char * klazz = NULL, * id = NULL; + /* skip over defs entries for now */ + if (ctx->in_defs) return; + if (atts != NULL) { for (i = 0; atts[i] != NULL; i += 2) @@ -323,6 +326,9 @@ rsvg_start_any_poly(RsvgHandle *ctx, const xmlChar **atts, gboolean is_polyline) GString * g = NULL; gchar ** pointlist = NULL; const char * klazz = NULL, * id = NULL; + + /* skip over defs entries for now */ + if (ctx->in_defs) return; if (atts != NULL) { @@ -385,9 +391,14 @@ rsvg_start_line (RsvgHandle *ctx, const xmlChar **atts) double x1 = 0, y1 = 0, x2 = 0, y2 = 0; GString * d = NULL; const char * klazz = NULL, * id = NULL; - RsvgState *state = &ctx->state[ctx->n_state - 1]; + RsvgState *state; char buf [G_ASCII_DTOSTR_BUF_SIZE]; + /* skip over defs entries for now */ + if (ctx->in_defs) return; + + state = &ctx->state[ctx->n_state - 1]; + if (atts != NULL) { for (i = 0; atts[i] != NULL; i += 2) @@ -431,10 +442,15 @@ rsvg_start_rect (RsvgHandle *ctx, const xmlChar **atts) double x = -1, y = -1, w = -1, h = -1, rx = 0., ry = 0.; GString * d = NULL; const char * klazz = NULL, * id = NULL; - RsvgState *state = &ctx->state[ctx->n_state - 1]; + RsvgState *state; char buf [G_ASCII_DTOSTR_BUF_SIZE]; gboolean got_rx = FALSE, got_ry = FALSE; + /* skip over defs entries for now */ + if (ctx->in_defs) return; + + state = &ctx->state[ctx->n_state - 1]; + if (atts != NULL) { for (i = 0; atts[i] != NULL; i += 2) @@ -474,26 +490,6 @@ rsvg_start_rect (RsvgHandle *ctx, const xmlChar **atts) y += 1.; /* emulate a rect using a path */ - /* - d = g_strdup_printf ("M %f %f " - "H %f " - "A %f,%f %f,%f %f %f,%f " - "V %f " - "A %f,%f %f,%f %f %f,%f " - "H %f " - "A %f,%f %f,%f %f %f,%f " - "V %f " - "A %f,%f %f,%f %f %f,%f", - x + rx, y, - x + w - rx, - rx, ry, 0., 0., 1., x + w, y + ry, - y + h - ry, - rx, ry, 0., 0., 1., x + w - rx, y + h, - x + rx, - rx, ry, 0., 0., 1., x, y + h - ry, - y + ry, - rx, ry, 0., 0., 1., x + rx, y); - */ d = g_string_new ("M "); g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + rx)); @@ -583,9 +579,14 @@ rsvg_start_circle (RsvgHandle *ctx, const xmlChar **atts) double cx = 0, cy = 0, r = 0; GString * d = NULL; const char * klazz = NULL, * id = NULL; - RsvgState *state = &ctx->state[ctx->n_state - 1]; + RsvgState *state; char buf [G_ASCII_DTOSTR_BUF_SIZE]; + /* skip over defs entries for now */ + if (ctx->in_defs) return; + + state = &ctx->state[ctx->n_state - 1]; + if (atts != NULL) { for (i = 0; atts[i] != NULL; i += 2) @@ -611,20 +612,6 @@ rsvg_start_circle (RsvgHandle *ctx, const xmlChar **atts) rsvg_parse_style_attrs (ctx, "circle", klazz, id, atts); /* approximate a circle using 4 bezier curves */ - /* - d = g_strdup_printf ("M %f %f " - "C %f %f %f %f %f %f " - "C %f %f %f %f %f %f " - "C %f %f %f %f %f %f " - "C %f %f %f %f %f %f " - "Z", - cx + r, cy, - cx + r, cy + r * RSVG_ARC_MAGIC, cx + r * RSVG_ARC_MAGIC, cy + r, cx, cy + r, - cx - r * RSVG_ARC_MAGIC, cy + r, cx - r, cy + r * RSVG_ARC_MAGIC, cx - r, cy, - cx - r, cy - r * RSVG_ARC_MAGIC, cx - r * RSVG_ARC_MAGIC, cy - r, cx, cy - r, - cx + r * RSVG_ARC_MAGIC, cy - r, cx + r, cy - r * RSVG_ARC_MAGIC, cx + r, cy - ); - */ d = g_string_new ("M "); g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), cx+r)); @@ -696,9 +683,14 @@ rsvg_start_ellipse (RsvgHandle *ctx, const xmlChar **atts) double cx = 0, cy = 0, rx = 0, ry = 0; GString * d = NULL; const char * klazz = NULL, * id = NULL; - RsvgState *state = &ctx->state[ctx->n_state - 1]; + RsvgState *state; char buf [G_ASCII_DTOSTR_BUF_SIZE]; + /* skip over defs entries for now */ + if (ctx->in_defs) return; + + state = &ctx->state[ctx->n_state - 1]; + if (atts != NULL) { for (i = 0; atts[i] != NULL; i += 2) @@ -724,20 +716,7 @@ rsvg_start_ellipse (RsvgHandle *ctx, const xmlChar **atts) rsvg_parse_style_attrs (ctx, "ellipse", klazz, id, atts); /* approximate an ellipse using 4 bezier curves */ - /* - d = g_strdup_printf ("M %f %f " - "C %f %f %f %f %f %f " - "C %f %f %f %f %f %f " - "C %f %f %f %f %f %f " - "C %f %f %f %f %f %f " - "Z", - cx + rx, cy, - cx + rx, cy - RSVG_ARC_MAGIC * ry, cx + RSVG_ARC_MAGIC * rx, cy - ry, cx, cy - ry, - cx - RSVG_ARC_MAGIC * rx, cy - ry, cx - rx, cy - RSVG_ARC_MAGIC * ry, cx - rx, cy, - cx - rx, cy + RSVG_ARC_MAGIC * ry, cx - RSVG_ARC_MAGIC * rx, cy + ry, cx, cy + ry, - cx + RSVG_ARC_MAGIC * rx, cy + ry, cx + rx, cy + RSVG_ARC_MAGIC * ry, cx + rx, cy - ); - */ + d = g_string_new ("M "); g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), cx + rx)); g_string_append_c (d, ' '); @@ -820,7 +799,12 @@ rsvg_start_image (RsvgHandle *ctx, const xmlChar **atts) guchar *rgb = NULL; int dest_rowstride; double tmp_affine[6]; - RsvgState *state = &ctx->state[ctx->n_state - 1]; + RsvgState *state; + + /* skip over defs entries for now */ + if (ctx->in_defs) return; + + state = &ctx->state[ctx->n_state - 1]; if (atts != NULL) { @@ -751,6 +751,7 @@ rsvg_defs_handler_end (RsvgSaxHandler *self, const xmlChar *name) ctx->handler->free (ctx->handler); ctx->handler = NULL; } + ctx->in_defs = FALSE; } /* pop the state stack */ @@ -768,7 +769,8 @@ rsvg_start_defs (RsvgHandle *ctx, const xmlChar **atts) handler->super.start_element = rsvg_defs_handler_start; handler->super.end_element = rsvg_defs_handler_end; handler->ctx = ctx; - + + ctx->in_defs = TRUE; ctx->handler = &handler->super; } @@ -837,7 +839,7 @@ rsvg_end_element (void *data, const xmlChar *name) { RsvgHandle *ctx = (RsvgHandle *)data; - if (ctx->handler_nest > 0) + if (ctx->handler_nest > 0 && ctx->handler != NULL) { if (ctx->handler->end_element != NULL) ctx->handler->end_element (ctx->handler, name); |