When we replace smiley whith <img> tag, his attributes such as alt (acronym) and title (smiley description) also can contain smiley acronym! Result see in attachment file "bug.png"

* Go to admin/settings/smileys/edit/1
* Set "Description" field to "Smiling :-)" (We just apend acronym)
* Save
* Craate new node, put ":)" smiley, and save them.
* You get broken <img> tag as on the screenshot (http://drupal.org/files/bug.png)

CommentFileSizeAuthor
bug.png3.96 KBstokito

Comments

stokito’s picture

Status: Active » Needs work

Ok. I am fix this bug, but without support of standalone smileys.

function smileys_filter_process($text) {
  $text = ' '. $text .' ';
  $replace_points = array();
  
  $smileys_list = get_smileys_list();
  foreach ($smileys_list as $smiley) {
    foreach ($smiley->acronyms_list as $acronym) {
  	  $acronym_length = strlen($acronym);  
      $acronym_pos = stripos($text, $acronym);
      while ($acronym_pos !== FALSE) { 
      	$replace_point = new stdClass();
      	$replace_point->acronym_length = $acronym_length;
//      	$replace_point->img = theme('smiley', $smiley, $acronym);
      	$replace_point->img = '<img src="'. check_url($GLOBALS['base_url'] .'/'. $smiley->image) .'" title="'. t($smiley->description) .'" alt="'. $acronim  .'" class="smiley-class" />';
      	$replace_points[$acronym_pos] = $replace_point;
        $acronym_pos = stripos($text, $acronym, $acronym_pos + $acronym_length);
      }
    }
  }
  
  ksort($replace_points);

  // Replace acronym on img tag in defined position
  // When img tag inserted in text next postions are shift.
  // So we insert img tag from end text to begin. 
  $replace_point = end($replace_points);
  if ($replace_point) {
	do {
	  $pos = key($replace_points);
	  $text = substr_replace($text, $replace_point->img, $pos, $replace_point->acronym_length);
  	  $replace_point = prev($replace_points);
    } while ($replace_point);
  }

  $text = substr($text, 1, -1);

  return $text;
}

P.S. It's take 1.5 hours, and I go to bed.

Gurpartap Singh’s picture

After following the steps you mentioned, I don't get any similar results. Perhaps the title field just has "Smiling :-)" and no image (it cant either, because this text isn't filtered).

Either this or I am unable to get your point. Please explain more.

Gurpartap Singh’s picture

Status: Needs work » Closed (fixed)

Closing the issue upon inactivity for a non-reproducible issue.