uc_fee.js: String.prototype.bytes
recrit - June 10, 2009 - 01:42
| Project: | Ubercart Fee |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
String.prototype.bytes is defined differently than in uc_taxes. This causes issues with uc_taxes when uc_fee is called after.
uc_fee:
String.prototype.bytes = function() {
return Drupal.encodeURIComponent(this).replace(/%../g, 'x').length;
};uc_taxes:
String.prototype.bytes = function() {
// Drupal.encodeURIComponent() gets around some weirdness in
// encodeURIComponent(), but encodes some characters twice. The first
// replace takes care of those while the second lets String.length count
// the multi-byte characters.
return Drupal.encodeURIComponent(this).replace(/%252[36F]/g, 'x').replace(/%../g, 'x').length;
};Suggestion: instead of overloading a primitive data type, define a custom function - str2bytes(str)

#1
This should be fixed in CVS. Re-releasing shortly.
#2
Automatically closed -- issue fixed for 2 weeks with no activity.