Browse Source

* Patch from Werner Pamler to fix getval

git-svn-id: trunk@43141 -
michael 5 years ago
parent
commit
0ccb7d951f
1 changed files with 8 additions and 5 deletions
  1. 8 5
      packages/chm/src/htmlutil.pas

+ 8 - 5
packages/chm/src/htmlutil.pas

@@ -119,11 +119,13 @@ begin
     inc(S); // skip space
     P:= S;
 
-    // Skip 
+    // Skip tag name
     while not (P^ in ['=', ' ', '>', #0]) do
       inc(P);
 
-    if (P^ = '=') then inc(P);
+    // Skip spaces and '='
+    while (P^ in ['=', ' ']) do
+      inc(P);
     
     while not (P^ in [' ','>',#0]) do
     begin
@@ -161,12 +163,15 @@ var
   S: Pchar;
   C: Char;
 begin
+  Result := '';
+
   P:= Pchar(namevalpair);
   S:= StrPos(P, '=');
 
   if S <> nil then     
   begin
     inc(S); // skip equal
+    while S^ = ' ' do inc(S);  // skip any spaces after =
     P:= S;  // set P to a character after =
 
     if (P^ in ['"','''']) then
@@ -181,9 +186,7 @@ begin
       inc(P);
 
     if (P <> S) then { Thanks to Dave Keighan ([email protected]) }
-      Result:= CopyBuffer(S, P - S) 
-    else
-      Result:= '';
+      Result:= CopyBuffer(S, P - S); 
   end;
 end;