#795294 by hass: Make account number validation more foolproof.
authorhass
Sun, 15 Aug 2010 16:54:48 +0000 (16:54 +0000)
committerhass
Sun, 15 Aug 2010 16:54:48 +0000 (16:54 +0000)
googleanalytics.admin.inc

index 93accad..c37cb06 100644 (file)
@@ -260,6 +260,12 @@ function googleanalytics_admin_settings_form(&$form_state) {
 }
 
 function googleanalytics_admin_settings_form_validate($form, &$form_state) {
+  // Trim some text values.
+  $form_state['values']['googleanalytics_account'] = trim($form_state['values']['googleanalytics_account']);
+  $form_state['values']['googleanalytics_pages'] = trim($form_state['values']['googleanalytics_pages']);
+  $form_state['values']['googleanalytics_codesnippet_before'] = trim($form_state['values']['googleanalytics_codesnippet_before']);
+  $form_state['values']['googleanalytics_codesnippet_after'] = trim($form_state['values']['googleanalytics_codesnippet_after']);
+
   if (!preg_match('/^UA-\d{4,}-\d+$/', $form_state['values']['googleanalytics_account'])) {
     form_set_error('googleanalytics_account', t('A valid Google Analytics account number is case sensitive and formatted like UA-xxxxxx-x.'));
   }
@@ -277,9 +283,4 @@ function googleanalytics_admin_settings_form_validate($form, &$form_state) {
   if (preg_match('/(.*)<\/?script(.*)>(.*)/i', $form_state['values']['googleanalytics_codesnippet_after'])) {
     form_set_error('googleanalytics_codesnippet_after', t('Do not include the &lt;script&gt; tags in the javascript code snippets.'));
   }
-
-  // Trim some text area values.
-  $form_state['values']['googleanalytics_pages'] = trim($form_state['values']['googleanalytics_pages']);
-  $form_state['values']['googleanalytics_codesnippet_before'] = trim($form_state['values']['googleanalytics_codesnippet_before']);
-  $form_state['values']['googleanalytics_codesnippet_after'] = trim($form_state['values']['googleanalytics_codesnippet_after']);
 }