kitsunyan / pakku

Pacman wrapper with AUR support
GNU General Public License v3.0
130 stars 8 forks source link

Crash when searching and a package's description is empty #54

Open kajong0007 opened 4 years ago

kajong0007 commented 4 years ago
$ pakku -Ss steam-cli-
aur/steam-cli-git 0.r27.b7583dc-1 [0 / 0.000000]
fatal.nim(39)            sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexError]
$ echo $?
1

This package in the AUR has a 0 length description. It causes pakku to crash here: https://github.com/kitsunyan/pakku/blob/master/src/format.nim#L152 I tested a change off of version 0.14 where I just didn't print anything if the description is empty:

  if len(description) > 0:
    let lines = description.get("").splitLines(getWindowSize().width - padding)
    for line in lines:
      echo(' '.repeat(padding), line)

output after change:

$ ./pakku -Ss steam-cli-
aur/steam-cli-git 0.r27.b7583dc-1 [0 / 0.000000]
$ echo $?
0 

I didn't do any searching for other areas where an empty string would cause issues, and as I don't know nim in the slightest, there is probably a more elegant solution.