diff options
| author | Martin Owens <doctormo@gmail.com> | 2013-09-12 17:37:52 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2013-09-12 17:37:52 +0000 |
| commit | f5b0c43114862ecd240d4ac78fe265e159873b14 (patch) | |
| tree | 8fa05841d420b3a77e698b1deff3af5ceb096d4c /src/xml/repr-io.cpp | |
| parent | Introduce a backup loading method that enables NOENT but hacks out system cal... (diff) | |
| download | inkscape-f5b0c43114862ecd240d4ac78fe265e159873b14.tar.gz inkscape-f5b0c43114862ecd240d4ac78fe265e159873b14.zip | |
Improve code with KosiĆski's regex replacement
(bzr r12505.1.2)
Diffstat (limited to 'src/xml/repr-io.cpp')
| -rw-r--r-- | src/xml/repr-io.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 364ff826a..d5088f3cf 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -203,12 +203,16 @@ int XmlSource::readCb( void * context, char * buffer, int len ) retVal = self->read( buffer, len ); if(self->SystemCheck) { - // Check for ENTITY SYSTEM entry and kill with fire - char *system = strstr(buffer, "SYSTEM"); - while (system != NULL) { - strncpy (system," ",6); - system = strstr(buffer, "SYSTEM"); - } + // Check for ENTITY SYSTEM cdata and kill with fire, does + // Break svg files who use entities for ns and system entities. + GRegex *entity_regex = g_regex_new( + "<!ENTITY\\s+[^>\\s]+\\s+SYSTEM\\s+\"[^>\"]+\"\\s*>", + G_REGEX_CASELESS, G_REGEX_MATCH_NEWLINE_ANY, NULL); + gchar *fixed_buffer = g_regex_replace( + entity_regex, buffer, len, 0, "", + G_REGEX_MATCH_NEWLINE_ANY, NULL); + g_regex_unref(entity_regex); + buffer = fixed_buffer; } } return retVal; @@ -974,12 +978,12 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, GQuark const absref_key = g_quark_from_static_string("sodipodi:absref"); gchar const *xxHref = 0; - gchar const *xxAbsref = 0; + //gchar const *xxAbsref = 0; for ( List<AttributeRecord const> ai(attributes); ai; ++ai ) { if ( ai->key == href_key ) { xxHref = ai->value; - } else if ( ai->key == absref_key ) { - xxAbsref = ai->value; + //} else if ( ai->key == absref_key ) { + //xxAbsref = ai->value; } } |
