cowsay is confused by input with ansi colour codes

Bug #1437804 reported by James Dingwall
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cowsay (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The maxlength function to construct the bubble calculates string length including escape sequences so although the colours are printed in the output the surrounding bubble is malformed, e.g.:

$ figlet "Hello World!" | toilet -f term --metal | /usr/games/cowsay -n

This can be solved by removing the escape sequences during string length calculations by applying one of the attached diffs. I have not tested the older versions one with an older perl to be certain it is correct.
(I am aware I could switch toilet / cowsay in the pipe but with this order I get a coloured message with a black and white cow.)

$ lsb_relase -rd
Description: Ubuntu 14.04.2 LTS
Release: 14.04

$ apt-cache policy cowsay
cowsay:
  Installed: 3.03+dfsg1-6
  Candidate: 3.03+dfsg1-6
  Version table:
 *** 3.03+dfsg1-6 0
        990 http://gb.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

Tags: patch
Revision history for this message
James Dingwall (a-james-launchpad) wrote :
Revision history for this message
James Dingwall (a-james-launchpad) wrote :

Support for older versions of perl

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "perl-5.13.2-and-up.diff" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Maltouzes (maltouzes)
Changed in cowsay (Ubuntu):
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cowsay - 3.03+dfsg1-14

---------------
cowsay (3.03+dfsg1-14) unstable; urgency=medium

  [ Tony Maillefaud ]
  * Add patch 03-ansi_code_width_color_widechar.patch
   - Good output format with widechar (closes: #769565)
   - Ignore ANSI codes when determining message width (LP: #10270033)
   - Good output with ANSI colour (LP: #1437804)

 -- Tony Maillefaud <email address hidden> Thu, 10 Dec 2015 09:17:59 +0100

Changed in cowsay (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.