[Koha-bugs] [Bug 14611] SMS::Send hangs on malformed mobile #, process_message_queue fails

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jul 30 17:53:27 CEST 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14611

--- Comment #2 from Fred P <fred.pierre at smfpl.org> ---
I guess the question boils down to how we prevent human error in the data
entry, and the method we select may not be foolproof. It's a bit complicated,
but we could regex-verify the string, allowing for numerics, plusses,
parentheses and hyphens - that would catch most of the errors. I'm not sure
that would prevent 100% of SMS::Send crashes, but it might. Basically we would
strip out unwanted characters on entry (or request a new entry) and hope
SMS::Send can properly handle "phone" characters. The documentation suggests
that plusses, parentheses and hyphens are not a problem, although I have not
tested for situations like ((330)) 678--5497

Converting our string to a numeric integer is another possibility, but parsing
that for visual display might be difficult, due to different global formulas.
Library staff don't want to look at ten or eleven numbers without hyphenation.
One way to implement a numeric conversion would be to keep the string saved,
and create a new field for the numeric - so you would have both. Adding fields
to the database is not the ideal solution though.

Google provides a library for testing and parsing phone numbers:
https://github.com/googlei18n/libphonenumber

This regex test might work, although many methods are possible with regex:
/^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\
\\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\
\\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/i

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list