Skip to content

Commit

Permalink
Merge pull request #888 from takayukister/dev/5.6
Browse files Browse the repository at this point in the history
Validation error for colons in name
  • Loading branch information
takayukister authored Jul 18, 2022
2 parents d70a51d + d02d151 commit 52b04c0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions includes/config-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WPCF7_ConfigValidator {
const error_unavailable_html_elements = 111;
const error_attachments_overweight = 112;
const error_dots_in_names = 113;
const error_colons_in_names = 114;

public static function get_doc_link( $error_code = '' ) {
$url = __( 'https://contactform7.com/configuration-errors/',
Expand Down Expand Up @@ -331,6 +332,7 @@ public function validate_form() {
$this->detect_unavailable_names( $section, $form );
$this->detect_unavailable_html_elements( $section, $form );
$this->detect_dots_in_names( $section, $form );
$this->detect_colons_in_names( $section, $form );
}

public function detect_multiple_controls_in_label( $section, $content ) {
Expand Down Expand Up @@ -454,6 +456,30 @@ public function detect_dots_in_names( $section, $content ) {
return false;
}


public function detect_colons_in_names( $section, $content ) {
$form_tags_manager = WPCF7_FormTagsManager::get_instance();

$tags = $form_tags_manager->filter( $content, array(
'feature' => 'name-attr',
) );

foreach ( $tags as $tag ) {
if ( false !== strpos( $tag->raw_name, ':' ) ) {
return $this->add_error( $section,
self::error_colons_in_names,
array(
'message' => __( "Colons are used in form-tag names.", 'contact-form-7' ),
'link' => self::get_doc_link( 'colons_in_names' ),
)
);
}
}

return false;
}


public function validate_mail( $template = 'mail' ) {
$components = (array) $this->contact_form->prop( $template );

Expand Down

0 comments on commit 52b04c0

Please sign in to comment.