Index: flag.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/flag.inc,v
retrieving revision 1.1.2.30.2.29
diff -u -p -r1.1.2.30.2.29 flag.inc
--- flag.inc	2 Sep 2010 04:53:47 -0000	1.1.2.30.2.29
+++ flag.inc	7 Sep 2010 09:47:25 -0000
@@ -692,8 +692,8 @@ class flag_flag {
       $this->_update_count($content_id);
     }
     // Remove anonymous cookies (if any).
-    if (isset($_COOKIE['flag'][$this->name . '_' . $content_id])) {
-      unset($_COOKIE['flags'][$this->name . '_' . $content_id]);
+    if (isset($_COOKIE['flag'][$this->get_css_name() . '_' . $content_id])) {
+      unset($_COOKIE['flags'][$this->get_css_name() . '_' . $content_id]);
     }
     return $fcid;
   }
@@ -724,7 +724,7 @@ class flag_flag {
   function _flag_anonymous($content_id) {
     // Global flags persist for the length of the minimum cache lifetime.
     if ($this->global) {
-      $cookie_key = 'flag_global_' . str_replace('_', '-', $this->name) . '_' . $content_id;
+      $cookie_key = 'flag_global_' . $this->get_css_name() . '_' . $content_id;
       $cookie_lifetime = (variable_get('cache', 0) > CACHE_DISABLED) ? variable_get('cache_lifetime', 0) : -1;
       // Do not let the cookie lifetime be 0 (which is the no cache limit on
       // anonymous page caching), since it would expire immediately. Usually
@@ -741,7 +741,7 @@ class flag_flag {
     else {
       $cookie_flags = isset($_COOKIE['flags']) ? $_COOKIE['flags'] : '';
       $cookie_flags = explode(' ', $cookie_flags);
-      $cookie_key = str_replace('_', '-', $this->name) . '_' . $content_id;
+      $cookie_key = $this->get_css_name() . '_' . $content_id;
       $cookie_lifetime = min((int) ini_get('session.cookie_lifetime'), (int) ini_get('session.gc_maxlifetime'));
       if (array_search($cookie_key, $cookie_flags) === FALSE) {
         $cookie_flags[] = $cookie_key;
@@ -760,7 +760,7 @@ class flag_flag {
   function _unflag_anonymous($content_id) {
     // Global flags are easy, just delete the global cookie.
     if ($this->global) {
-      $cookie_key = 'flag_global_' . str_replace('_', '-', $this->name) . '_' . $content_id;
+      $cookie_key = 'flag_global_' . $this->get_css_name() . '_' . $content_id;
       $cookie_lifetime = (variable_get('cache', 0) > CACHE_DISABLED) ? variable_get('cache_lifetime', 0) : -1;
       // Do not let the cookie lifetime be 0 (which is the no cache limit on
       // anonymous page caching), since it would expire immediately. Usually
@@ -776,7 +776,7 @@ class flag_flag {
     else {
       $cookie_flags = isset($_COOKIE['flags']) ? $_COOKIE['flags'] : '';
       $cookie_flags = explode(' ', $cookie_flags);
-      $cookie_key = str_replace('_', '-', $this->name) . '_' . $content_id;
+      $cookie_key = $this->get_css_name() . '_' . $content_id;
       $cookie_lifetime = min((int) ini_get('session.cookie_lifetime'), (int) ini_get('session.gc_maxlifetime'));
       $cookie_index = array_search($cookie_key, $cookie_flags);
       if ($cookie_index !== FALSE) {
@@ -1099,7 +1099,8 @@ class flag_flag {
       if (!isset($js_added[$this->name . '_' . $content_id])) {
         $js_added[$this->name . '_' . $content_id] = TRUE;
         $js_template = theme($this->theme_suggestions(), $this, 'unflag', $content_id, $after_flagging);
-        drupal_add_js(array('flag' => array('templates' => array($this->name . '_' . $content_id => $js_template))), 'setting');
+        // Use CSS name.
+        drupal_add_js(array('flag' => array('templates' => array($this->get_css_name() . '_' . $content_id => $js_template))), 'setting');
       }
     }
 
@@ -1115,6 +1116,13 @@ class flag_flag {
     $suggestions[] = 'flag';
     return $suggestions;
   }
+
+  /**
+   * Provides an css name for a given flag.
+   */
+  function get_css_name() {
+    return str_replace('_', '-', $this->name);
+  }
 }
 
 /**
Index: flag.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/flag.module,v
retrieving revision 1.11.2.72.2.47
diff -u -p -r1.11.2.72.2.47 flag.module
--- flag.module	2 Sep 2010 03:55:54 -0000	1.11.2.72.2.47
+++ flag.module	7 Sep 2010 09:47:26 -0000
@@ -1161,7 +1161,7 @@ function template_preprocess_flag(&$vari
   $flag =& $variables['flag'];
   $action = $variables['action'];
   $content_id = $variables['content_id'];
-  $flag_css_name = str_replace('_', '-', $flag->name);
+  $flag_css_name = $flag->get_css_name();
 
   // Generate the link URL.
   $link_type = $flag->get_link_type();
