URL decodedFields causes ArgumentOutOfRange exception

Project:GNU Smalltalk
Component:NetClients
Category:bug
Priority:normal
Assigned:Unassigned
Status:active
Description
url := URL fromString: '?key=value'.
fields := url decodedFields.
fields printNl.


Object: 'key=value' error: Invalid argument 0: argument must be between 4 and 9
SystemExceptions.ArgumentOutOfRange(Smalltalk.Exception)>>signal (ExcHandling.st:254)
SystemExceptions.ArgumentOutOfRange(Smalltalk.Exception)>>signal: (ExcHandling.st:264)
SystemExceptions.ArgumentOutOfRange class>>signalOn:mustBeBetween:and: (SysExcept.st:599)
Smalltalk.String(Smalltalk.ArrayedCollection)>>copyFrom:to: (ArrayColl.st:230)
[] in URL>>decodedFields (URL.st:535)
Smalltalk.OrderedCollection>>do: (OrderColl.st:68)
URL>>decodedFields (URL.st:541)
Smalltalk.UndefinedObject>>executeStatements (test.st:3)
nil

It seems to be a typo in this method. The size of 'key=value' is needed when extracting the 'value':

keyValue size

But found:

value size

So after fixing:

LookupTable (
	'key'->'value'
)

Patch

--- URL.st      2014-08-16 15:47:28.156523910 +0400
+++ URL_patch.st        2014-08-16 15:48:45.112521892 +0400
@@ -525,7 +525,7 @@
                key := keyValue copyFrom: 1 to: i - 1.
                i < keyValue size
                    ifTrue:
-                       [value := keyValue copyFrom: i + 1 to: value size.
+                       [value := keyValue copyFrom: i + 1 to: keyValue size.
                        value := URL decode: value].
                self
                    add: key

Updates

#1 submitted by Holger Hans Pet... on Sat, 08/16/2014 - 20:03

Hi!

ah, your patch wasn't sent to the mailinglist and I came up with the same patch. I am going to include a fix later today.

User login