Tags:
create new tag
view all tags

SID-02046: SEARCH: URLPARAM multiple attribute causes syntax error

Status: Answered Answered TWiki version: 4.3.0 Perl version:
Category: CategorySearch Server OS: Linux Last update: 11 years ago

I'd like to allow users to find documentation based on report output by indicating which report headings (or "columns") they need. Each report manual has a TWiki Form with checkboxes for the different columns, and there are corresponding checkboxes on the Search page. Using the Spreadsheet Plugin, I've devloped the proper search string, but the SEARCH box rejects it due to a syntax error. However, when I copy/paste the string from the topic, it works.

-- Jamie Benjamin - 2015-03-31

Here is the code for the search page:

<form name="websearch" id="reportsearch" action="/cgi-bin/view/Support/SID-02046" accept-charset="UTF-8">
<input type="hidden" name="table" value="1" />
<input type="hidden" name="sortcol" value="0" />
<input type="hidden" name="up" value="1" />
<div style="font-size:1.1em;">Find a Report:</div>
<input type="text" name="query" value="" size="32" />
<div style="font-size:1.1em;">Columns:</div>
<input type="checkbox" name="cols" value="APR" /><label for="APR"> APR</label>

<input type="checkbox" name="cols" value="Payoff Amount" /><label for="Payoff Amount"> Payoff Amount</label>

<input type="checkbox" name="cols" value="Unearned Finance Charge" /><label for="Unearned Finance Charge"> Unearned Finance Charge</label>

<input type="submit" value="Search" />
</form>




* Columns List:
* Set COLSIZE = 0
* Adding query to list:
* Set COLJOIN =


Could not perform search. Error was: Empty expression

Here is a sample of the form:

Name Type Size Values   Topic text 50 SID-02046   Summary textarea 50X5     Keywords textarea 50X5     Programs textarea 50X5     Filters textarea 50X5     Cols checkbox 5 APR, Current Balance, Finance Charge, Interest Rate, Payoff Amount, Remaining Term, Unearned Finance Charge, Unpaid Interest
</verbatim>

NOTE:

I found another way to get it to work, but it's not as elegant and will be harder to maintain. For now, it will just have to do:


<form name="websearch" id="reportsearch" action="/cgi-bin/view/Support/SID-02046" accept-charset="UTF-8">
<input type="hidden" name="table" value="1" />
<input type="hidden" name="sortcol" value="0" />
<input type="hidden" name="up" value="1" />
<div style="font-size:1.1em;">Find a Topic:</div>
<input type="text" name="query" value="" size="32" />

<input type="checkbox" name="apr" value="1" /><label for="APR"> APR</label>

<input type="checkbox" name="payoff" value="1" /><label for="Payoff Amount"> Payoff Amount</label>

<input type="checkbox" name="unearnedfc" value="1" /><label for="Unearned Finance Charge"> Unearned Finance Charge</label>

<input type="submit" value="Search" />
</form>

* Set TOPICSEARCH = $IF($SEARCH((?i), $topic),1,0)
* Set KEYWORDSEARCH = $IF($SEARCH((?i), $formfield(Keywords)),1,0)
* Set PROGRAMSEARCH = $IF($SEARCH((?i), $formfield(Programs)),1,0)
* Set QUERY =
* Set APR =
* Set PAYOFF =
* Set UNEARNEDFC =


%QUERY%

%APR%

%UNEARNEDFC%



%QUERY%, %APR%, %PAYOFF%, %UNEARNEDFC%

* Set REPORTSEARCH = %QUERY% OR %APR% OR %PAYOFF% OR %UNEARNEDFC%

<div id="hidesearch" style="display:none;">
Could not perform search. Error was: Syntax error in '%REPORTSEARCH%' at '%REPORTSEARCH%'
</div>


Discussion and Answer

Oh, there's another victim of the problems to enter verbatim stuff in a support form...

Whatever. Your problem is easily understood in raw view.

Here's the gotcha: URLPARAM does some escaping on input for security reasons, which is the right thing. However, it does it after applying $item formatting. I can't say whether this is intentional or not, but here's the fix: Instead of

   * Set COLJOIN = %CALCULATE{$LISTJOIN($sp OR $sp, $GETLIST(columns))}%
...you need to undo the escaping of the single quote:
   * Set COLJOIN = %CALCULATE{$SUBSTITUTE($LISTJOIN($sp OR $sp, $GETLIST(columns)),&#39;,')}%

Have a look at the HTML source of your 'syntax error' report: It contains '&#39;' where you expect single quotes. Copy and paste works, because you did it from the browser display, where the escaping has also been undone by the browser during rendering the page.

Have a look at Sandbox/SidUrlparam where I tried to bring your example to life, not too well, but maybe good enough.

-- Harald Jörg - 2015-03-31

Thank you, Harald! I appreciate it!

(And yes, I stuggled with the input form, as you noticed. I can't stand the WYSIWYG editor. It's disabled on my TWiki site. Give me raw code, any day!)

-- Jamie Benjamin - 2015-03-31

Answered. smile

-- Jamie Benjamin - 2015-03-31

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title SEARCH: URLPARAM multiple attribute causes syntax error
SupportCategory CategorySearch
TWiki version 4.3.0
Server OS Linux
Web server Apache
Perl version

Browser & version Firefox 36.0
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2015-03-31 - JamieBenjamin
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.