Opened 10 years ago

Closed 10 years ago

#13669 closed defect (duplicate)

Urlencode string filter should add "0" padding on values 0 to 9

Reported by: Jonathan Owned by: Neil Roberts
Priority: low Milestone: 1.8
Component: DojoX DTL Version: 1.6.1
Keywords: urlencode, hex needsreview Cc:
Blocked By: Blocking:


dojox.dtl.filter.strings.urlencode("\t"); returns "%9" instead of "%09". Same for any hex value between 0 and 9.

Though you can argue that's a valid base 16 number, it really doesn't work in a URL environment.

For example, when putting a string containing "\tB" through this urlencode() method, it returns "%9B", which obviously gets decoded as ">". Oops.

At the time of writing (changeset 25909 in trunk), the buggy line is here:

A fix that worked for me was to prepend "00", and then use slice(-2) to ensure we have two digits:

var hexBaseValue = token.charCodeAt(0).toString(16).toUpperCase();

return "%" + String("00" + hexBaseValue).slice(-2);

There are obviously different approaches to add the padding for these 10 values.

Change History (4)

comment:1 Changed 10 years ago by bill


Moving apparently forgotten ticket to 1.8.

comment:2 Changed 10 years ago by ben hockey

Keywords: needsreview added
Priority: highlow

is this a duplicate of #12932 or is it a request for the opposite of what #12932 is about?

comment:3 Changed 10 years ago by Jonathan

It's a duplicate, but #12932 has been closed due to the reporter not following up. The issue is still valid so I'll comment there. Please close this one and re-open #12932.

comment:4 Changed 10 years ago by ben hockey

Resolution: duplicate
Status: newclosed

Duplicate of #12932.

Note: See TracTickets for help on using tickets.