From 8d7ba042778a55a15f76dc708cd68803a743d231 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Sun, 14 Mar 2021 11:38:38 -0700 Subject: [PATCH] don't require F5 forms other than first one to have any particular name/ID This allow-list of known forms is a relic of the HTML-form-parsing code which was originally written for the Juniper protocol, and requires a bunch of special-casing. I don't think it's particularly relevant for F5 forms. Signed-off-by: Daniel Lenski --- f5.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/f5.c b/f5.c index 162e0fb6..624b6803 100644 --- a/f5.c +++ b/f5.c @@ -87,7 +87,7 @@ static int check_cookie_success(struct openconnect_info *vpninfo) int f5_obtain_cookie(struct openconnect_info *vpninfo) { - int ret; + int ret, form_order=0; xmlDocPtr doc = NULL; xmlNode *node; struct oc_text_buf *req_buf = NULL; @@ -98,7 +98,7 @@ int f5_obtain_cookie(struct openconnect_info *vpninfo) if ((ret = buf_error(req_buf))) goto out; - while (1) { + while (++form_order) { char *resp_buf = NULL; char *url; @@ -141,16 +141,15 @@ int f5_obtain_cookie(struct openconnect_info *vpninfo) buf_truncate(req_buf); node = find_form_node(doc); - if (!node) { + if (!node && form_order==1) { /* XX: some F5 VPNs simply do not have a static HTML form to parse */ vpn_progress(vpninfo, PRG_ERR, _("WARNING: no HTML login form found; assuming username and password fields\n")); if ((form = plain_auth_form()) == NULL) goto nomem; } else { - if (!xmlnode_get_prop(node, "id", &form_id) && !strcmp(form_id, "auth_form")) - form = parse_form_node(vpninfo, node, NULL, FORM_FLAVOR_F5, NULL); - else { + form = parse_form_node(vpninfo, node, NULL, FORM_FLAVOR_F5, NULL); + if (form_order==1 && (xmlnode_get_prop(node, "id", &form_id) || strcmp(form_id, "auth_form"))) { vpn_progress(vpninfo, PRG_ERR, _("Unknown form ID '%s' (expected 'auth_form')\n"), form_id); -- 2.49.0