[DRE-maint] Bug#557023: Barby::Code128: private method split called for nil
Gunnar Wolf
gwolf at gwolf.org
Wed Nov 25 16:13:46 UTC 2009
tags 557023 = pending
thanks
Hmm... Looking more closely to your submitted patches: The second part
makes sense (using an empty string when a nil is presented), although
its correctness might be stylistic (i.e. some authors prefer to raise
an exception on an anomalous condition, which you can catch outside
their module).
However, I fail to understand the first patch: Code128's «extra=»
function currently implements a simple validation to see whether the
supplied extra is valid; your first patch (libbarby-ruby-0.3.2.patch)
ends up being a minor optimization (as, right, CODEA+CODEB+CODEC are
known to be present at the beginning of the string), but do not really
solve the problem.
As for the second patch (libbarby-ruby-0.3-better.patch), you put it
in the «data=» function. I think it would be better to locate the fix
in the «characters» function, without modifying any data structure in
the process:
diff --git a/lib/barby/barcode/code_128.rb b/lib/barby/barcode/code_128.rb
index 1525369..46ff894 100644
--- a/lib/barby/barcode/code_128.rb
+++ b/lib/barby/barcode/code_128.rb
@@ -236,7 +236,7 @@ module Barby
#characters like FNC1 will be present. Characters from extras are not
#present.
def characters
- chars = data.split(//n)
+ chars = (data||'').split(//n)
if type == 'C'
result = []
This patch fixes the first case in your example code, but not the
second one - As I told you, I am unsure whether the author implemented
the exception raising on purpose — Clearly an empty string will not
result in a valid barcode!
I am removing the "pending" tag from this bug - I'd like to get your
input on my reasoning, as well as the author's, before applying any of
the preceding solutions.
--
Gunnar Wolf • gwolf at gwolf.org • (+52-55)5623-0154 / 1451-2244
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-ruby-extras-maintainers/attachments/20091125/7724f0f1/attachment.pgp>
More information about the Pkg-ruby-extras-maintainers
mailing list