Skip to content

Commit

Permalink
0.5.2.1: Some DTMF-related bugfixes
Browse files Browse the repository at this point in the history
 - Ivr#sayAndHandleDigits: use DMTF.`#` not '#'
 - Sayables#digitWords: sanitization
  • Loading branch information
nafg committed Aug 14, 2018
1 parent d37a0c7 commit 7ac4649
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/simpleivr/Ivr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Ivr(sayables: Sayables) {
case (acc, x) =>
def sayDigitOrDigits(n: Int) = numberWords(n) & (if (n == 1) `digit` else `digits`)

val str = acc + x.filter(_ != '#').mkString
val str = acc + x.filter(_ != DTMF.`#`).mkString
val validated =
if ((min == max) && (str.length != min)) Left(`You must enter ` & sayDigitOrDigits(min))
else if (str.length < min) Left(`You must enter at least` & sayDigitOrDigits(min))
Expand Down
8 changes: 7 additions & 1 deletion core/src/main/scala/simpleivr/Sayables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ abstract class Sayables(val audioFileBackend: AudioFileBackend) extends Speaks {
}
}

def digitWords(s: String): Sayable = Sayable.Many(s.toSeq.map(c => numberWords(c - '0')))
def digitWords(digitString: String): Sayable =
Sayable.Many(
digitString
.map(_ - '0')
.filter(d => d >= 0 && d <= 9)
.map(numberWords)
)

def dtmfWord(c: DTMF): Sayable = c match {
case DTMF.`#` => `pound`
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.5.2"
ThisBuild / version := "0.5.2.1"

0 comments on commit 7ac4649

Please sign in to comment.