thirdy / durian

Path of Exile Items watcher
http://thirdy.github.io/durian/
GNU General Public License v2.0
35 stars 10 forks source link

Changed how ItemNamesConfig and ItemWatchConfig parses files. Fixes #1. #2

Closed Dryvnt closed 8 years ago

Dryvnt commented 8 years ago

The regular expressions probably aren't perfect, but they should fix this specific bug I was having, as well as avoid others like it that might have showed up.

thirdy commented 8 years ago

Can you describe this specific bug?

Note the following documentation in itemwatch.txt

; This is a comment
; Each line represent 1 item watch
; There are 4 required information, the League, Full Item Name, Currency and Amount, separated by a pipe '|'
; These token will be trimmed, e.g. "   chaos   " will be read as "chaos"

Standard|Tabula Rasa|chaos|5
Dryvnt commented 8 years ago

I described the bug in the issue I put here. Issue #1, even! :p

Basically an empty itemwatch file somehow passes the filter, which then leads to an out of bounds exception when this line gets split and indexed into.

As for what this fix does: I changed the filters for ItemWatch and ItemName to use regular expressions instead. I haven't found a bug with ItemName, but being consistent can't hurt, and it protects against a malformed file.

These regular expressions only matches lines that don't begin with ';', that then have some text followed by a '|' followed by some text etc., until the appropriate amount of pipes have been found.

This should also safeguard against malformed itemwatch lists, where people forgot pipes or some such.

thirdy commented 8 years ago

I pushed a unit test, I'm suspecting there's a problem with how I used the split method. Can your run ItemWatchConfigTest on your machine?

As for the regex, I think the pipe should be escape as in "^;.+|.+" I'll look into this more.

Thanks btw.

thirdy commented 8 years ago

i merged in your changes, but no I'm getting IndexOutOfBounds. So I made a bit of adjustment to your regex.

Let me know that doesn't work for you.

Dryvnt commented 8 years ago

Seems to work fine for me, I'd consider this issue fixed and closed.