Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug in URL parsing that affected Ajax callbacks in GemStone #932

Closed
marianopeck opened this issue Jul 11, 2017 · 3 comments
Closed

Bug in URL parsing that affected Ajax callbacks in GemStone #932

marianopeck opened this issue Jul 11, 2017 · 3 comments
Milestone

Comments

@marianopeck
Copy link
Contributor

In GemStone 3.3 and 3.4 (at least) when using JQAjax >> script: withOUT the line "self cache: true" (which is the current latest state of seaside), the AJAX URLs are generated with something like this:

   '/reps?_s=eDS_xgsDW-eVq1Ki&_k=VjtmcpSz91iFIGsw&94&_=1499735755608

When in requestUrlFor: we parse the URL we get bad results:

    (WAUrl absolute: '/reps?_s=eDS_xgsDW-eVq1Ki&_k=VjtmcpSz91iFIGsw&94&_=1499735755608') queryFields ->aWARequestFields('_s'->'eDS_xgsDW-eVq1Ki' '_k'->'VjtmcpSz91iFIGsw' '94&_'->'' '_'->'1499735755608')

When that should have been:

     (WAUrl absolute: '/reps?_s=eDS_xgsDW-eVq1Ki&_k=VjtmcpSz91iFIGsw&94&_=1499735755608') 	queryFields -> aWARequestFields('_s'->'eDS_xgsDW-eVq1Ki' '_k'->'VjtmcpSz91iFIGsw' '94'->nil '_'->'1499735755608')

It seems to be a problem in the query parsing code in WAUr>>#parseQuery:from:to:

It doesn't check if the nameEnd is less than the parameterEnd, only the queryEnd. So when an unnamed query parameter isn't last in the series of queries (like the callback parameter that precedes the cache busting parameter) then things aren't parsed properly.

	WAUrl>>parseQuery: aString from: queryStart to: queryEnd
	| parameterStart |
	parameterStart := queryStart.
	[ parameterStart > 0 and: [ parameterStart < queryEnd ] ]
	 whileTrue: [
	   | nameEnd parameterEnd |
	   nameEnd := aString indexOf: $= startingAt: parameterStart.
	   parameterEnd := aString indexOf: $& startingAt: parameterStart.
	   parameterEnd := parameterEnd > 0
	     ifTrue: [ parameterEnd min: queryEnd ]
	     ifFalse: [ queryEnd ].
	   (nameEnd > 0 and: [ nameEnd < parameterEnd  ])
	     ifTrue: [
	       self
	         addField:
	           (self class decodePercentAndPlus: aString from: parameterStart to: nameEnd)
	         value:
	           (self class decodePercentAndPlus: aString from: nameEnd + 1 to: parameterEnd) ]
	     ifFalse: [
	       self
	         addField:
	           (self class decodePercentAndPlus: aString from: parameterStart to: parameterEnd) ].
	   parameterStart := parameterEnd + 1 ]

I will see if I can make a PR soon.

@jbrichau
Copy link
Member

Is #909 related? The same?

@jbrichau
Copy link
Member

@marianopeck Sorry that I was not able to relate your issue earlier on to this one.
I'll make a bugfix release asap.

@marianopeck
Copy link
Contributor Author

@jbrichau no problem...it was really hard to track it down up to discover what was broken. It was impossible to figure out.

jbrichau pushed a commit that referenced this issue Jul 14, 2017
Fix for issue #932 by merging in fix of issue #909 from dev branch
@jbrichau jbrichau added this to the 3.2.4 milestone Jul 18, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants