@ -588,7 +588,7 @@ else if(contentType.equals(HTML_CONTENT_TYPE))
processedString = processImgTags ( processedString ,
contentType ) ;
}
return processSmilies ( processedString , contentType ) ;
}
@ -686,11 +686,6 @@ private String processSmilies(String message, String contentType)
}
else
{
if ( HTML_CONTENT_TYPE . equals ( contentType ) )
{
message = removeAltFromHTMLSmilies ( message ) ;
}
startPlainTextTag = "" ;
endPlainTextTag = "" ;
}
@ -699,6 +694,8 @@ private String processSmilies(String message, String contentType)
StringBuffer regexp = new StringBuffer ( ) ;
regexp . append ( "(?<!(alt='|alt=\"))(" ) ;
for ( int i = 0 ; i < smiliesList . size ( ) ; i + + )
{
@ -714,6 +711,8 @@ private String processSmilies(String message, String contentType)
}
regexp = regexp . deleteCharAt ( regexp . length ( ) - 1 ) ;
regexp . append ( ')' ) ;
Pattern p = Pattern . compile ( regexp . toString ( ) ) ;
Matcher m = p . matcher ( message ) ;
@ -741,64 +740,6 @@ private String processSmilies(String message, String contentType)
return msgBuffer . toString ( ) ;
}
/ * *
* Removes alt content from the smilies contained in html messages . This
* is needed in order to process html smilies properly . If ' : ) ' is not
* removed , then it will be replaced by the html < img > tag in the
* processSmilies method and this will cause having an < img > tag within
* another < img > tag and a malformatted html .
*
* @param content the message content
* @return formatted messages content
* /
private String removeAltFromHTMLSmilies ( String content )
{
StringBuffer result = new StringBuffer ( ) ;
StringBuffer smileyRegexp = new StringBuffer ( ) ;
//building supported smilies list
ArrayList smiliesList = ImageLoader . getDefaultSmiliesPack ( ) ;
for ( int i = 0 ; i < smiliesList . size ( ) ; i + + )
{
Smiley smiley = ( Smiley ) smiliesList . get ( i ) ;
String [ ] smileyStrings = smiley . getSmileyStrings ( ) ;
for ( int j = 0 ; j < smileyStrings . length ; j + + )
{
smileyRegexp . append ( GuiUtils . replaceSpecialRegExpChars (
smileyStrings [ j ] ) ) . append ( "|" ) ;
}
}
smileyRegexp . deleteCharAt ( smileyRegexp . length ( ) - 1 ) ;
//creating pattern string. we want to remove all smilies that appear
//in the 'alt' attribute of an '<img>' tag, like <img alt=":)" src=... >
String imgPattern = "<img (.*alt=\"|')(.*?)"
+ smileyRegexp . toString ( )
+ "(.*?)(\"|')(.*?)>" ;
Pattern p = Pattern . compile ( imgPattern , Pattern . CASE_INSENSITIVE ) ;
Matcher imgFinder = p . matcher ( content ) ;
boolean foundMatch = false ;
//creating escaped message
while ( imgFinder . find ( ) )
{
if ( ! foundMatch )
foundMatch = true ;
String matchGroup = imgFinder . group ( ) ;
String replacement =
matchGroup . replaceAll ( smileyRegexp . toString ( ) , "" ) ;
imgFinder . appendReplacement ( result ,
GuiUtils . replaceSpecialRegExpChars ( replacement ) ) ;
}
imgFinder . appendTail ( result ) ;
return result . toString ( ) ;
}
/ * *
* Opens a link in the default browser when clicked and shows link url in a
* popup on mouseover .