Example #1
0
    def _handle_option_tag_inside_form(self, tag, tag_name, attrs):
        """
        Handler for option tag inside a form
        """
        option_value = get_value_by_key(attrs, 'value')

        if option_value:
            self._select_option_values.add(option_value)
Example #2
0
File: html.py Project: zcr214/w3af
    def _handle_option_tag_inside_form(self, tag, tag_name, attrs):
        """
        Handler for option tag inside a form
        """
        option_value = get_value_by_key(attrs, 'value')

        if option_value:
            self._select_option_values.add(option_value)
Example #3
0
    def _handle_select_tag_inside_form(self, tag, tag_name, attrs):
        """
        Handler for select tag inside a form
        """
        select_name = get_value_by_key(attrs, 'name', 'id')

        if select_name:
            self._select_input_name = select_name
Example #4
0
File: html.py Project: zcr214/w3af
    def _handle_select_tag_inside_form(self, tag, tag_name, attrs):
        """
        Handler for select tag inside a form
        """
        select_name = get_value_by_key(attrs, 'name', 'id')

        if select_name:
            self._select_input_name = select_name
Example #5
0
    def _handle_textarea_tag_inside_form(self, tag, tag_name, attrs):
        """
        Handler for textarea tag inside a form
        """
        SGMLParser._handle_textarea_tag_start(self, tag, tag_name, attrs)

        # Set the data and name
        self._text_area_data = tag.text
        self._text_area_tag_name = get_value_by_key(attrs, 'name', 'id')
Example #6
0
File: html.py Project: zcr214/w3af
    def _handle_textarea_tag_inside_form(self, tag, tag_name, attrs):
        """
        Handler for textarea tag inside a form
        """
        SGMLParser._handle_textarea_tag_start(self, tag, tag_name, attrs)

        # Set the data and name
        self._text_area_data = tag.text
        self._text_area_tag_name = get_value_by_key(attrs, 'name', 'id')
Example #7
0
    def _handle_select_tag_start(self, tag, tag_name, attrs):
        if not self._inside_form:
            return

        self._select_tag_name = get_value_by_key(attrs, 'name', 'id')

        if self._select_tag_name:
            self._inside_select = True
        else:
            self._inside_select = False
Example #8
0
    def _handle_select_tag_start(self, tag, tag_name, attrs):
        if not self._inside_form:
            return

        self._select_tag_name = get_value_by_key(attrs, 'name', 'id')

        if self._select_tag_name:
            self._inside_select = True
        else:
            self._inside_select = False
Example #9
0
    def form_field_factory(self, attributes):
        """
        Create a new form field (in most cases) or update an existing FormField
        instance.

        :param attributes: The tag attributes for the newly found form input
        :return: The newly created / updated form field
        """
        input_name = get_value_by_key(attributes, 'name', 'id')

        if input_name is None:
            return False, None

        # shortcut
        snf = self.meta.get(input_name, [])

        # Find the attr type and value, setting the default type to text (if
        # missing in the tag) and the default value to an empty string (if
        # missing)
        input_type = get_value_by_key(attributes, 'type') or INPUT_TYPE_TEXT
        input_type = input_type.lower()

        input_value = get_value_by_key(attributes, 'value') or ''

        autocomplete = get_value_by_key(attributes, 'autocomplete') or ''
        autocomplete = False if autocomplete.lower() == 'off' else True

        should_add_new = True

        if input_type == INPUT_TYPE_SELECT:
            input_values = get_value_by_key(attributes, 'values') or []
            form_field = SelectFormField(input_name, input_values)

        elif input_type == INPUT_TYPE_RADIO:
            match_fields = [
                ff for ff in snf if ff.input_type is INPUT_TYPE_RADIO
            ]

            if match_fields:
                form_field = match_fields[-1]
                form_field.values.append(input_value)
                should_add_new = False
            else:
                form_field = RadioFormField(input_name, [input_value])

        elif input_type == INPUT_TYPE_CHECKBOX:
            match_fields = [
                ff for ff in snf if ff.input_type is INPUT_TYPE_CHECKBOX
            ]

            if match_fields:
                form_field = match_fields[-1]
                form_field.values.append(input_value)
                should_add_new = False
            else:
                form_field = CheckboxFormField(input_name, [input_value])

        elif input_type == INPUT_TYPE_FILE:
            file_name = get_value_by_key(attributes, 'filename')
            form_field = FileFormField(input_name,
                                       value=input_value,
                                       file_name=file_name)

        else:
            form_field = GenericFormField(input_type,
                                          input_name,
                                          input_value,
                                          autocomplete=autocomplete)

        return should_add_new, form_field
Example #10
0
    def form_field_factory(self, attributes):
        """
        Create a new form field (in most cases) or update an existing FormField
        instance.

        :param attributes: The tag attributes for the newly found form input
        :return: The newly created / updated form field
        """
        input_name = get_value_by_key(attributes, 'name', 'id')

        if input_name is None:
            return False, None

        # shortcut
        snf = same_name_fields = self.meta.get(input_name, [])

        # Find the attr type and value, setting the default type to text (if
        # missing in the tag) and the default value to an empty string (if
        # missing)
        input_type = get_value_by_key(attributes, 'type') or INPUT_TYPE_TEXT
        input_type = input_type.lower()

        input_value = get_value_by_key(attributes, 'value') or ''

        autocomplete = get_value_by_key(attributes, 'autocomplete') or ''
        autocomplete = False if autocomplete.lower() == 'off' else True

        should_add_new = True

        if input_type == INPUT_TYPE_SELECT:
            input_values = get_value_by_key(attributes, 'values') or []
            form_field = SelectFormField(input_name, input_values)

        elif input_type == INPUT_TYPE_RADIO:
            match_fields = [ff for ff in snf if ff.input_type is INPUT_TYPE_RADIO]

            if match_fields:
                form_field = match_fields[-1]
                form_field.values.append(input_value)
                should_add_new = False
            else:
                form_field = RadioFormField(input_name, [input_value])

        elif input_type == INPUT_TYPE_CHECKBOX:
            match_fields = [ff for ff in snf if ff.input_type is INPUT_TYPE_CHECKBOX]

            if match_fields:
                form_field = match_fields[-1]
                form_field.values.append(input_value)
                should_add_new = False
            else:
                form_field = CheckboxFormField(input_name, [input_value])

        elif input_type == INPUT_TYPE_FILE:
            file_name = get_value_by_key(attributes, 'filename')
            form_field = FileFormField(input_name,
                                       value=input_value,
                                       file_name=file_name)

        else:
            form_field = GenericFormField(input_type, input_name, input_value,
                                          autocomplete=autocomplete)

        return should_add_new, form_field