Changeset 607


Ignore:
Timestamp:
Sep 9, 2010, 4:31:02 PM (9 years ago)
Author:
lindanl
Message:

Check for encoding. Only process UTF-8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/template.c

    r600 r607  
    349349  chars_avail = min(chars_read,BUFFER_SIZE);
    350350 
     351  if(chars_read<4){
     352    fprintf(stderr,"File is too short. Not well formed.\n");
     353    exit(-1);
     354  }
     355 
    351356  tag_matcher t(srcbuf);
    352357
    353358  Entity_Info * e = new Entity_Info;
    354359  e->AnalyzeSignature((unsigned char *)srcbuf);
    355   XML_Decl_Parser<ASCII> decl_parser((unsigned char *)srcbuf);
    356 
    357   decl_parser.ReadXMLInfo(*e); 
    358 
     360
     361  if (e->code_unit_base == ASCII) {
     362                       
     363    XML_Decl_Parser<ASCII> decl_parser((unsigned char *)srcbuf);
     364
     365    decl_parser.ReadXMLInfo(*e); 
     366   
     367    if (e->code_unit_size != SingleByte || (e->has_encoding_decl && (!at_UTF_8(e->encoding)))){
     368        fprintf(stderr,"Sorry, we only process UTF-8.\n");
     369        exit(-1);
     370    }
     371  }
     372  else {
     373    fprintf(stderr,"Sorry, we don't process EBCDIC.\n");
     374        exit(-1);
     375  }
     376 
    359377  if (e->content_start != 0) {
    360378        memmove(&srcbuf[0], &srcbuf[e->content_start], chars_read - e->content_start);
Note: See TracChangeset for help on using the changeset viewer.