You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Karan Rajanayagam <ka...@dossier.no> on 2012/06/19 00:47:54 UTC

PageTester cant handle querystring ?

PageTester cant handle query string.. for ex. an link like:  
admin/clazz/edit?schoolYearId=0


Im getting StringIndexOutOfBounds because an error in PageTester class.,


PageTester class we have:

/  private void setupRequestFromURI(String URI)
     {
         String linkPath = stripContextFromPath(URI);

         int comma = linkPath.indexOf('?');

         String path = comma < 0 ? linkPath : linkPath.substring(0, comma);

         request.clear().setPath(path);

         if (comma > 0)
*            decodeParametersIntoRequest(path.substring(comma + 1));*
     }
/
Last line should rather be:
*  decodeParametersIntoRequest(*linkPath*.substring(comma + 1));*

Shall i fire a bug ?
-- 
  Kind regards
*Karan Rajanayagam*

Re: PageTester cant handle querystring ?

Posted by Steve Eynon <st...@alienfactory.co.uk>.
There is also a duplicate JIRA for the PageTester bug and a patch file here:

REOPEN TAP5-698 - PageTester's setupRequestFromURI incorrectly uses
substring twice on same string
https://issues.apache.org/jira/browse/TAP5-1936

Steve.
--
Steve Eynon
-------------------------------
"If at first you don't succeed,
   so much for skydiving!"



On 19 June 2012 17:37, Steve Eynon <st...@alienfactory.co.uk> wrote:
> A colleague already filed this JIRA last year:
>
> PageTester causes StringIndexOutOfBoundsException with query parameter
> https://issues.apache.org/jira/browse/TAP5-1770
>
> While you're at it, you may also wish to patch TestableRequestImpl
> with the following:
>
> @Override
> public TestableRequest clear() {
>        parameters.clear();
>
>        /* ---- MUNKY PATCH ---------------------------------------------------- */
>        // Fudge for T5 PageTester not clearing down Request Attributes
>        // Needed to clear the OpenSpringSessionInViewFilter.FILTERED flag
>        attributes.clear();
>        /* ---- MUNKY PATCH ---------------------------------------------------- */
>
>        return this;
> }
>
> @Override
> public TestableRequest setPath(String path) {
>        /* ---- MUNKY PATCH ---------------------------------------------------- */
>        // strip any anchor information off the path URL 'cos
>        //  1. it's not supposed to be there
>        //  2. T5 throws up if it finds it!
>        if (path.contains("#")) {
>                path = path.substring(0, path.indexOf('#'));
>        }
>        /* ---- MUNKY PATCH ---------------------------------------------------- */
>        this.path = path;
>        return this;
> }
>
> --
> Steve Eynon
> -------------------------------
> "If at first you don't succeed,
>    so much for skydiving!"
>
>
>
> On 19 June 2012 06:47, Karan Rajanayagam <ka...@dossier.no> wrote:
>>
>> PageTester cant handle query string.. for ex. an link like:
>>  admin/clazz/edit?schoolYearId=0
>>
>>
>> Im getting StringIndexOutOfBounds because an error in PageTester class.,
>>
>>
>> PageTester class we have:
>>
>> /  private void setupRequestFromURI(String URI)
>>    {
>>        String linkPath = stripContextFromPath(URI);
>>
>>        int comma = linkPath.indexOf('?');
>>
>>        String path = comma < 0 ? linkPath : linkPath.substring(0, comma);
>>
>>        request.clear().setPath(path);
>>
>>        if (comma > 0)
>> *            decodeParametersIntoRequest(path.substring(comma + 1));*
>>    }
>> /
>> Last line should rather be:
>> *  decodeParametersIntoRequest(*linkPath*.substring(comma + 1));*
>>
>> Shall i fire a bug ?
>> --
>>  Kind regards
>> *Karan Rajanayagam*

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: PageTester cant handle querystring ?

Posted by Steve Eynon <st...@alienfactory.co.uk>.
A colleague already filed this JIRA last year:

PageTester causes StringIndexOutOfBoundsException with query parameter
https://issues.apache.org/jira/browse/TAP5-1770

While you're at it, you may also wish to patch TestableRequestImpl
with the following:

@Override
public TestableRequest clear() {
	parameters.clear();

	/* ---- MUNKY PATCH ---------------------------------------------------- */
	// Fudge for T5 PageTester not clearing down Request Attributes
	// Needed to clear the OpenSpringSessionInViewFilter.FILTERED flag
	attributes.clear();
	/* ---- MUNKY PATCH ---------------------------------------------------- */

	return this;
}

@Override
public TestableRequest setPath(String path) {
	/* ---- MUNKY PATCH ---------------------------------------------------- */
	// strip any anchor information off the path URL 'cos
	//  1. it's not supposed to be there
	//  2. T5 throws up if it finds it!
	if (path.contains("#")) {
		path = path.substring(0, path.indexOf('#'));
	}
	/* ---- MUNKY PATCH ---------------------------------------------------- */
	this.path = path;
	return this;
}

--
Steve Eynon
-------------------------------
"If at first you don't succeed,
   so much for skydiving!"



On 19 June 2012 06:47, Karan Rajanayagam <ka...@dossier.no> wrote:
>
> PageTester cant handle query string.. for ex. an link like:
>  admin/clazz/edit?schoolYearId=0
>
>
> Im getting StringIndexOutOfBounds because an error in PageTester class.,
>
>
> PageTester class we have:
>
> /  private void setupRequestFromURI(String URI)
>    {
>        String linkPath = stripContextFromPath(URI);
>
>        int comma = linkPath.indexOf('?');
>
>        String path = comma < 0 ? linkPath : linkPath.substring(0, comma);
>
>        request.clear().setPath(path);
>
>        if (comma > 0)
> *            decodeParametersIntoRequest(path.substring(comma + 1));*
>    }
> /
> Last line should rather be:
> *  decodeParametersIntoRequest(*linkPath*.substring(comma + 1));*
>
> Shall i fire a bug ?
> --
>  Kind regards
> *Karan Rajanayagam*

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org