Prechádzať zdrojové kódy

Allow empty "file-name" value.

Jordan Russell 2 mesiacov pred
rodič
commit
424ff2b4c9
2 zmenil súbory, kde vykonal 4 pridanie a 3 odobranie
  1. 2 2
      Components/ISSigFunc.pas
  2. 2 1
      Components/StringScanner.pas

+ 2 - 2
Components/ISSigFunc.pas

@@ -124,7 +124,7 @@ begin
   Result := False;
   Result := False;
   if SS.Consume(AIdent) and SS.Consume(' ') and (not ARequireQuotes or SS.Consume('"')) then
   if SS.Consume(AIdent) and SS.Consume(' ') and (not ARequireQuotes or SS.Consume('"')) then
     if SS.ConsumeMultiToString(AAllowedChars, AValue, AAllowAllCharsAboveFF,
     if SS.ConsumeMultiToString(AAllowedChars, AValue, AAllowAllCharsAboveFF,
-       AMinValueLength, AMaxValueLength) > 0 then begin
+       AMinValueLength, AMaxValueLength) >= AMinValueLength then begin
       if not ARequireQuotes or SS.Consume('"') then begin
       if not ARequireQuotes or SS.Consume('"') then begin
         { CRLF and LF line breaks are allowed (but not CR) }
         { CRLF and LF line breaks are allowed (but not CR) }
         SS.Consume(#13);
         SS.Consume(#13);
@@ -243,7 +243,7 @@ begin
   var SS := TStringScanner.Create(AText);
   var SS := TStringScanner.Create(AText);
   if not ConsumeLineValue(SS, 'format', TextValues.Format, 8, 8, NonControlASCIICharsSet) or
   if not ConsumeLineValue(SS, 'format', TextValues.Format, 8, 8, NonControlASCIICharsSet) or
      ((TextValues.Format <> 'issig-v1') and ((TextValues.Format <> 'issig-v2'))) or
      ((TextValues.Format <> 'issig-v1') and ((TextValues.Format <> 'issig-v2'))) or
-     ((TextValues.Format = 'issig-v2') and not ConsumeLineValue(SS, 'file-name', TextValues.FileName, 1, MaxInt,
+     ((TextValues.Format = 'issig-v2') and not ConsumeLineValue(SS, 'file-name', TextValues.FileName, 0, MaxInt,
        (NonControlASCIICharsSet - ['"']) + AllHighCharsSet, True, True)) or
        (NonControlASCIICharsSet - ['"']) + AllHighCharsSet, True, True)) or
      not ConsumeLineValue(SS, 'file-size', TextValues.FileSize, 1, 16, DigitsSet) or
      not ConsumeLineValue(SS, 'file-size', TextValues.FileSize, 1, 16, DigitsSet) or
      not ConsumeLineValue(SS, 'file-hash', TextValues.FileHash, 64, 64, HexDigitsSet) or
      not ConsumeLineValue(SS, 'file-hash', TextValues.FileHash, 64, 64, HexDigitsSet) or

+ 2 - 1
Components/StringScanner.pas

@@ -73,7 +73,8 @@ function TStringScanner.ConsumeMulti(const AAllowedChars: TSysCharSet;
   const AAllowAllCharsAboveFF: Boolean = False; const AMinChars: Integer = 1;
   const AAllowAllCharsAboveFF: Boolean = False; const AMinChars: Integer = 1;
   const AMaxChars: Integer = MaxInt): Integer;
   const AMaxChars: Integer = MaxInt): Integer;
 begin
 begin
-  if (AMinChars <= 0) or (AMinChars > AMaxChars) then
+  { AMinChars may be 0; it functions the same as 1 }
+  if (AMinChars < 0) or (AMinChars > AMaxChars) then
     raise Exception.Create('TStringScanner.ConsumeMulti: Invalid parameter');
     raise Exception.Create('TStringScanner.ConsumeMulti: Invalid parameter');
 
 
   const Remain = GetRemainingCount;
   const Remain = GetRemainingCount;