diff --git a/redirect.admin.inc b/redirect.admin.inc index 880f596..001b43c 100644 --- a/redirect.admin.inc +++ b/redirect.admin.inc @@ -473,6 +473,13 @@ function redirect_element_validate_redirect($element, &$form_state) { form_error($element, t('The redirect path %value is not valid.', array('%value' => $value))); } + // validate internal URLs so redirects cannot lead to 404 pages. + if (variable_get('redirect_validate_internal_url') == 1) { + if (!drupal_valid_path($value)) { + form_error($element, t('The redirect path %value is not valid.', array('%value' => $value))); + } + } + return $element; } @@ -636,6 +643,11 @@ function redirect_settings_form($form, &$form_state) { '#description' => t('Only redirects managaged by the redirect module itself will be deleted. Redirects managed by other modules will be left alone.'), '#disabled' => variable_get('redirect_page_cache', 0) && !variable_get('page_cache_invoke_hooks', TRUE), ); + $form['redirect_validate_internal_url'] = array( + '#type' => 'checkbox', + '#title' => t('Validate internal URLs so redirects cannot lead to 404 pages.'), + '#default_value' => variable_get('redirect_validate_internal_url', 0), + ); $form['globals'] = array( '#type' => 'fieldset',