Bug 205978

Summary: comms/smstools3: sendsms script not compatible with FreeBSD iconv
Product: Ports & Packages Reporter: DmitryBond <satorium77>
Component: Individual Port(s)Assignee: Guido Falsi <madpilot>
Status: Closed FIXED    
Severity: Affects Many People Keywords: needs-qa
Priority: --- Flags: madpilot: maintainer-feedback+
Version: Latest   
Hardware: amd64   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=205973

Description DmitryBond 2016-01-06 19:23:45 UTC
Hi!

Sending SMS using sendsms script and UTF8 text as argument script not working as it should.

How to reproduce:

1. sendsms 7903xxxxxxx "ั‚ะตัั‚"
2. on mobile phone you will see something but not you're expecting

The reason of it is in this part of sendsms script:

ALPHABET=""
if which iconv > /dev/null 2>&1; then
  if ! $ECHO -n "$TEXT" | iconv -t ISO-8859-15 >/dev/null 2>&1; then
    ALPHABET="Alphabet: UCS"
  fi
fi

iconv in FreeBSD returns 0 exit code even if there were some invalid chars, so "Alphabet: UCS" will never be set.

How to fix:

1. If there are some errors in conversion iconv in FreeBSD will return message in stderr which can be parsed. So to fix this bug the code above should be replaced with:

ALPHABET=""
if which iconv > /dev/null 2>&1; then
  if $ECHO -n "$TEXT" | iconv -t ISO-8859-15 2>&1 | grep "invalid" > /dev/null; then
    ALPHABET="Alphabet: UCS"
  fi
fi
Comment 1 Guido Falsi freebsd_committer freebsd_triage 2016-01-17 13:47:02 UTC
Hi, forgot to reply to this. I'm going to implement this one too. Thanks!
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-11-02 11:30:07 UTC
A commit references this bug:

Author: madpilot
Date: Wed Nov  2 11:29:29 UTC 2016
New revision: 425138
URL: https://svnweb.freebsd.org/changeset/ports/425138

Log:
  - Add UTF8 option [1]
  - Patch sendsms script to correctly parse iconv command output [2]

  While here:

  - Add TIMESTAMP to distinfo
  - Regenerate patches
  - Unsilence post-install target

  PR:		205973 [1], 205978 [2]
  Submitted by:	satorium77@gmail.com

Changes:
  head/comms/smstools3/Makefile
  head/comms/smstools3/distinfo
  head/comms/smstools3/files/patch-Makefile
  head/comms/smstools3/files/patch-examples-smsd.conf.easy
  head/comms/smstools3/files/patch-install.sh
  head/comms/smstools3/files/patch-scripts_sendsms
  head/comms/smstools3/files/patch-src-Makefile
Comment 3 Guido Falsi freebsd_committer freebsd_triage 2016-11-02 11:30:30 UTC
Changes committed. Thanks!