Opened 10 years ago
Closed 9 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: |
Description
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: http://bugs.dojotoolkit.org/browser/dojo/dojox/trunk/dtl/filter/strings.js#L27
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 9 years ago by
Milestone: | 1.6.2 → 1.8 |
---|
comment:2 Changed 9 years ago by
Keywords: | needsreview added |
---|---|
Priority: | high → low |
Moving apparently forgotten ticket to 1.8.