Bug available_choice_select_inputs() incorrectly parses <select> tags

philmasterplus

Active member
KoLmafia r20631: Due to a flawed regex pattern in ChoiceUtilities.java, the available_choice_select_inputs() function incorrectly parses certain choice adventures. For example, the Fortune Teller page contains the following HTML:

HTML:
<select name="which" id="which" required>
...
</select>

The regex tries to match the value of the name attribute, but matches which" id="which" required instead.

I'm posting a patch that fixes this. Since parsing HTML with regex is inherently tricky, I rewrote the methods parseSelectInputsWithTags() and parseTextInputs() using HtmlCleaner and XPath instead. I also added a couple of test cases for them.

Note that parseSelectInputsWithTags() is also called by several functions that process choice adventures. This patch may cause unforeseen breakages. While a quick playtest revealed no problems, I still feel it needs a bit more testing before being integrated.
 

Attachments

  • philmasterplus-fix-choice-parsing.patch
    14.1 KB · Views: 2

philmasterplus

Active member
I've been dogfooding this patch on 3 different characters for over a week and found no issues. May I request integrating this (possibly after a code review)?
 
Top