Opened 16 years ago

Closed 16 years ago

#2516 closed defect (fixed)

ILI2 driver slow to detect that big XML files are not ILI2

Reported by: Even Rouault Owned by: pka
Priority: normal Milestone: 1.6.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: ili2
Cc:

Description

If we do an ogrinfo on a XML file that is neither ILI2, GPX, KML, GML, the Xerces parser of ILI2 driver will try to parse it complitely.

The heuristic test is not sufficient or buggy:

/* -------------------------------------------------------------------- */
/*      If we aren't sure it is ILI2, load a header chunk and check      */
/*      for signs it is ILI2                                             */
/* -------------------------------------------------------------------- */
    if( bTestOpen )
    {
        int nLen = (int)VSIFRead( szHeader, 1, sizeof(szHeader), fp );
        if (nLen == sizeof(szHeader))
            szHeader[sizeof(szHeader)-1] = '\0';
        else
            szHeader[nLen] = '\0';

        if( szHeader[0] != '<' 
            && strstr(szHeader,"interlis.ch/INTERLIS2") == NULL )
        { // "www.interlis.ch/INTERLIS2.2"
            VSIFClose( fp );
            CSLDestroy( filenames );
            return FALSE;
        }
    }
I would say we should replace the '&&' by a '
' in the test.

Right ? Pirmin can you confirm ?

Change History (3)

comment:1 by Even Rouault, 16 years ago

hum Trac eat what I wanted to write. I mean replace 'logical and operator' by 'logical or operator'

comment:2 by pka, 16 years ago

A Ili2 file looks like:

<?xml version="1.0" encoding="UTF-8"?>

<!-- File RoadsExgm2ien_symbols.xml 2003-04-14 -->

<!-- Dokumentenhistorie: -->
<!--   2003-02-26 - MG  - Original -->
<!--   2004-01-13 - SFK - ALIAS and some object references -->

<TRANSFER 
  xmlns="http://www.interlis.ch/INTERLIS2.2" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.interlis.ch/INTERLIS2.2
  StandardSymbology.xsd">

  <HEADERSECTION VERSION="2.2" SENDER="V+D">

The test is looking at the first character for checking wheter it's an XML file and then searching the first 1000 characters for the Interlis namespace.

Evan: logial or makes more sense, yes.

comment:3 by Even Rouault, 16 years ago

Keywords: ili2 added
Milestone: 1.6.0
Resolution: fixed
Status: newclosed

Fixed in trunk in r15089

Note: See TracTickets for help on using tickets.