use of net.htmlparser.jericho.FormField in project zaproxy by zaproxy.
the class SpiderHtmlFormParser method prepareFormDataSet.
/**
* Prepares the form data set. A form data set is a sequence of control-name/current-value pairs
* constructed from successful controls, which will be sent with a GET/POST request for a form.
*
* @see <a href="https://www.w3.org/TR/REC-html40/interact/forms.html#form-data-set">HTML 4.01 Specification - 17.13.3
* Processing form data</a>
* @see <a href="https://html.spec.whatwg.org/multipage/forms.html#association-of-controls-and-forms">HTML 5 - 4.10.18.3
* Association of controls and forms</a>
* @param form the form
* @return the list
*/
private FormData prepareFormDataSet(FormFields form) {
List<HtmlParameter> formDataSet = new LinkedList<>();
List<HtmlParameter> submitFields = new ArrayList<>();
// Process each form field
Iterator<FormField> it = form.iterator();
while (it.hasNext()) {
FormField field = it.next();
if (log.isDebugEnabled()) {
log.debug("New form field: " + field.getDebugInfo());
}
List<HtmlParameter> currentList = formDataSet;
if (field.getFormControl().getFormControlType().isSubmit()) {
currentList = submitFields;
}
for (String value : getDefaultTextValue(field)) {
currentList.add(new HtmlParameter(Type.form, field.getName(), value));
}
}
return new FormData(formDataSet, submitFields);
}
use of net.htmlparser.jericho.FormField in project zaproxy by zaproxy.
the class SpiderHtmlFormParser method prepareFormDataSet.
/**
* Prepares the form data set. A form data set is a sequence of control-name/current-value pairs
* constructed from successful controls, which will be sent with a GET/POST request for a form.
*
* @see <a href="https://www.w3.org/TR/REC-html40/interact/forms.html#form-data-set">HTML 4.01
* Specification - 17.13.3 Processing form data</a>
* @see <a
* href="https://html.spec.whatwg.org/multipage/forms.html#association-of-controls-and-forms">HTML
* 5 - 4.10.18.3 Association of controls and forms</a>
* @param source the source where the form is (to obtain further input elements)
* @param form the form
* @return the list
*/
private FormData prepareFormDataSet(Source source, Element form) {
List<FormDataField> formDataFields = new LinkedList<>();
// Process each form field
Iterator<FormField> it = getFormFields(source, form).iterator();
while (it.hasNext()) {
FormField field = it.next();
if (getLogger().isDebugEnabled()) {
getLogger().debug("New form field: " + field.getDebugInfo());
}
for (String value : getDefaultTextValue(field)) {
formDataFields.add(new FormDataField(field.getName(), value, field.getFormControl().getFormControlType().isSubmit()));
}
}
return new FormData(formDataFields);
}
Aggregations