Skip to content

Commit

Permalink
form refactoring for pattern matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
benibela committed Jul 7, 2024
1 parent 74c267c commit 9659e46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 2 additions & 9 deletions data/extendedhtmlparser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ function guessExtractionKind(e: string): TExtractionKind;

implementation

uses math,strutils,bbutilsbeta, xquery.internals.common, xquery.internals.protectionbreakers;
uses math,strutils,bbutilsbeta, xquery.internals.common, xquery.internals.protectionbreakers,htmlformutils;

const //TEMPLATE_COMMANDS=[tetCommandMeta..tetCommandIfClose];
firstRealTemplateType = tetMatchElementOpen;
Expand Down Expand Up @@ -2058,13 +2058,6 @@ function THtmlTemplateParser.matchLastTrees: Boolean;
var oldVariableCount: SizeInt;

procedure setFinalFormRequest;
function getAssociatedForm(t: TTreeNode): TTreeNode;
begin
result := t;
while (result <> nil) and not striEqual(result.value, 'form') do
result := result.parent;
end;

var allRequests: TXQValueList;
currentForm: TTreeNode = nil;
currentRequest: TXQValueList;
Expand All @@ -2075,7 +2068,7 @@ function THtmlTemplateParser.matchLastTrees: Boolean;
if currentForm = nil then exit;
formArgs[0] := xqvalue(currentForm);
formArgs[1] := xqvalueSeqSqueezed(currentRequest);
request := TXQueryEngine.findNativeModule(XMLNamespaceURL_MyExtensionsNew).findComplexFunction('form', 2, xqpmXQuery4_0).func(FQueryContext, 2, @formArgs[0]);
request := xqFunctionForm(FQueryContext, 2, @formArgs[0]);
allRequests.add(request);
currentRequest := TXQValueList.create();
end;
Expand Down
4 changes: 3 additions & 1 deletion data/tests/extendedhtmlparser_tests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,9 @@ procedure unitTests(testerrors: boolean);
tformrequest('<form><input name="a" t:form-request=""/><input name="b" t:form-request=""/><input name="c" t:form-request=""/></form>', '', '{"method": "GET", "url": "unittest?a=x&b=y&c=z"}');
tformrequest('<form><input name="a" t:form-request="1"/><input name="b" t:form-request="23"/><input name="c" t:form-request="''bar''"/></form>', '', '{"method": "GET", "url": "unittest?a=1&b=23&c=bar"}');
tformrequest('<form><input name="a" t:form-request="''foo''"/><input name="c" t:form-request="''bar''"/></form>', '', '{"method": "GET", "url": "unittest?a=foo&b=y&c=bar"}');

tformrequest('<form><select name="sel" t:form-request=""></select></form>', '<form><select name="sel"><option value="A"/><option value="B"/></select></form>', '{"method": "GET", "url": "unittest?sel=A"}');
tformrequest('<form><select name="sel" t:form-request="''x''"></select></form>', '<form><select name="sel"><option value="A"/><option value="B"/></select></form>', '{"method": "GET", "url": "unittest?sel=x"}');
tformrequest('<form><select name="sel"><option value="B" t:form-request=""/></select></form>', '<form><select name="sel"><option value="A"/><option value="B"/></select></form>', '{"method": "GET", "url": "unittest?sel=B"}');

xstring('hallo"''"''world', 'hallo"''"''world');
xstring('foo{1+2}bar', 'foo3bar');
Expand Down

0 comments on commit 9659e46

Please sign in to comment.