htmanning has asked for the wisdom of the Perl Monks concerning the following question:
Here is the script:<a href="javascript:popUp('/cgi-bin/script.pl?favadd=yes&num=6210&fav +title=jones\'s title&favlink=6210.html')">
I get the confirmation pages like I'm supposed to, but nothing goes in the database. If I take out this line:$favtitle = param('favtitle'); if ($favadd && $username_valid == 1) { if ($favtitle && $favlink) { $favtitle =~ s/\\'/\'/g; $favorites = $favorites . "$favtitle|||$favlink|||$num~~~"; $oldtitle = $favtitle; $oldlink = $favlink; @favs = split /~~~/,$favorites; if (@favs > $maxfavs) { print <<HTML; Currently, the maximum number is $maxfavs. <br> <br>Max number reached! <br> <br> <font face="arial" size="-1"><a href="javascript:window.close()">Close + Window</a></font> HTML } else { @sorted = sort {uc($a) cmp uc($b)} @favs; $favorites = ""; foreach (@sorted){ ($favtitle,$favlink,$num) = split /\|\|\|/,$_; $favorites = $favorites . $favtitle . "|||" . $favlink + . "|||" . $num . "~~~"; } # update existing record $SQL = "UPDATE $regtable SET favorites='$favorites' WHERE +ID='$ID'"; &Do_SQL; # get favorites $favslist = ""; $rowcolor = "#EEEEEE"; @favs = split /~~~/,$favorites; foreach (@favs){ ($favtitle,$favlink,$num) = split /\|\|\|/,$_; $favslist = $favslist . "<tr><td bgcolor=$rowcolor><a +href=\"$favlink\">$favtitle</a></td></tr>"; # alternate grey and white bar if ($rowcolor eq "#EEEEEE") { $rowcolor = "#FFFFFF"; } else { $rowcolor = "#EEEEEE"; } # end if ($rowcolor eq "#EEEEEE") } $favslist = "<table border=0 width=100% cellpadding=4 cell +spacing=0><tr><td> <b>My Saves:</b><br></td></tr>".$favslist."</table +>"; print <<HTML; Saved! HTML
It makes no difference. If I don't escape the apostrophe in the javascript the popup doesn't work. The only way I can get it to work is to completely remove the apostrophe in the javascript link, but then the title goes in the database without an apostrophe which isn't ideal. The other weird thing is, if I don't use a javascript popup, and force people to change pages to the confirmatoin page, it works with the apostrophe. See anything I'm doing wrong? Thanks.$favtitle =~ s/\\'/\'/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Escaping then un-escaping an apostrophe
by wind (Priest) on Mar 10, 2011 at 19:52 UTC | |
by htmanning (Friar) on Mar 10, 2011 at 20:53 UTC | |
by wind (Priest) on Mar 10, 2011 at 21:09 UTC | |
by Anonymous Monk on Mar 10, 2011 at 21:07 UTC | |
|
Re: Escaping then un-escaping an apostrophe
by ikegami (Patriarch) on Mar 10, 2011 at 20:09 UTC |