Skip to content

httpdefs.pp TRequest.ProcessQueryString parser error

Bug in module httpdefs.pp

The method TRequest.ProcessQueryString incorrectly processes a request if last field containing 1 character. In this case last field will be lost. For example for query string 1&2&3&4 we got 3 field, for query "a" (query of 1 character) we got 0 fields. Problem is in function NextToken inside ProcessQueryString method. I have changed this function and propose the following patch.

function NextToken(out aToken : String; out aSepChar : Char) : Boolean;

  var
    i : Integer;
    j : Integer;
    BoT : Integer;
    EoT : Integer;
    isSep : Boolean;

  begin
    if aPos > aLenStr then Exit(false);
    Result := true;
    BoT:=aPos;
    EoT:=aPos;
    for i:=aPos to aLenStr do
      begin
      IsSep := false;
      for j := 1 to aLenSep do
        begin
        if aString[i] = aSepStr[j] then
          begin
          IsSep := true;
          Break;
          end;
        end;
      if IsSep then
        begin
        EoT  := i;
        aPos := i + 1;
        aSepChar := aString[i];
        Break;
        end
      else
        begin
        if i = aLenStr then
          begin
          EoT  := i + 1;
          aPos := i + 1;
          Break;
          end;
        end;
      end;

    aToken := Copy(aString, BoT, EoT - BoT);
  end;
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information