Show
Ignore:
Timestamp:
15.02.2011 19:23:25 (9 years ago)
Author:
ak19
Message:

Fix to server-crashing bug where, when loading the titles classifier, a Title's contents were mistaken for metadata since it contained an open square bracket. The code now is a bit more resilient as it checks for the presence of an open square bracket and close square bracket (in that order) before assuming it is format-related Metadata.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/formattools.cpp

    r23515 r23707  
    17481748  text_t::const_iterator here = text.begin(); 
    17491749  text_t::const_iterator end = text.end(); 
     1750 
     1751  char startbracket = '['; 
     1752  char endbracket = ']'; 
     1753 
     1754  char bracket = startbracket; 
    17501755  while (here != end) { 
    1751     if (*here == '[') return true; 
     1756      if (*here == bracket) { 
     1757          if(bracket == startbracket) {  
     1758              // seen a [, next look for a ] to confirm it's metadata 
     1759              bracket = endbracket;  
     1760          } else if(bracket == endbracket) {  
     1761              // found [ ... ] in text, so we think it includes metadata 
     1762              return true; 
     1763          } 
     1764      } 
    17521765    ++here; 
    17531766  }