jearbear
09-09-2010, 04:42 PM
Hello! I'm working with a website in which my clients are entering text into a rich text editor. My client wants character counts generated, so, I put in code to take the rich text and strip out all tags or anything inside of them. This proved to be a bit squirrely, so, I ended up with this:
my $temptitle = $FORM{'title'};
$temptitle =~ s/<(.*?)>//g;
$temptitle =~ s/\n+/\t/g;
$temptitle =~ s/<[a-zA-Z\/][^>]*>//g; #tags again count issue
if(length($temptitle)>130){
my $titlelength=length($temptitle);
$is_errors++;
$error_messages=$error_messages."Your title is $titlelength - longer than the maximum 130 characters. Please shorten it. It currently reads as $temptitle<br>\n";
}
if($is_errors){print "<center>$error_messages<br><br>\n<a href=\"javascript:history.go(-1)\">Go back and make changes</a>";}
This works for me fine on a mac running safari, IE5, or chrome.
But, when they attempt to use the same script from a pc, things go haywire.
For example, the text: "Competition, Historical Geography, and Community Assembly Rules – Birds of the Bismarck and Solomon Islands" comes out fine for me. I get the proper character count. It prints out like normal text.
But, when they use the same cgi, they get the following as the deparsed text
Your title is 1343 - longer than the maximum 130 characters. Please shorten it. It currently reads as Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:'Table Normal'; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:''; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:'Calibri','sans-serif'; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:'Times New Roman'; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:'Times New Roman'; mso-bidi-theme-font:minor-bidi;} Competition
Note, they aren't using IE4 either. What is going on here?
my $temptitle = $FORM{'title'};
$temptitle =~ s/<(.*?)>//g;
$temptitle =~ s/\n+/\t/g;
$temptitle =~ s/<[a-zA-Z\/][^>]*>//g; #tags again count issue
if(length($temptitle)>130){
my $titlelength=length($temptitle);
$is_errors++;
$error_messages=$error_messages."Your title is $titlelength - longer than the maximum 130 characters. Please shorten it. It currently reads as $temptitle<br>\n";
}
if($is_errors){print "<center>$error_messages<br><br>\n<a href=\"javascript:history.go(-1)\">Go back and make changes</a>";}
This works for me fine on a mac running safari, IE5, or chrome.
But, when they attempt to use the same script from a pc, things go haywire.
For example, the text: "Competition, Historical Geography, and Community Assembly Rules – Birds of the Bismarck and Solomon Islands" comes out fine for me. I get the proper character count. It prints out like normal text.
But, when they use the same cgi, they get the following as the deparsed text
Your title is 1343 - longer than the maximum 130 characters. Please shorten it. It currently reads as Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:'Table Normal'; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:''; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:'Calibri','sans-serif'; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:'Times New Roman'; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:'Times New Roman'; mso-bidi-theme-font:minor-bidi;} Competition
Note, they aren't using IE4 either. What is going on here?