469,275 Members | 1,569 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Problem showing apostrophe and double quotes, on web page

114 100+
I have an ASP news page to which you can add comments. The comments open up in a new window, and users can click reply to reply to them after which they are taken to the parent page which has a comment form to fill in. The comments show fine, except when you click reply, and they contain either the " or the ' ie, apostrophe or double quotes, . what happens with the apostrophe is that instead of an

'

it shows


ampersand, hash, 39 and semicolon. (I tried adding them here, but they turned into an apostrophe. so i had to edit this post and type in this sentence)

One of the include files that is the "inc.api.asp" has the code for all this i think, and i think it needs altering somewhere. I'm not sure if it's the parent page inc_api code that needs altering or the pop page which shows the comment.

Here is part of the inc_api.com page with the relevant code which may need fixing. Any suggestions welcome. Thanks in advance

Expand|Select|Wrap|Line Numbers
  1. <p>
  2.   <% 
  3. '// REPLACES INVALID CHARS FROM STRING TO BE PASSED INTO JavaScript
  4. '// REPLACES THE FOLLOWING CHARS: "-'-(-) with `-`-[-`]
  5. FUNCTION FIX_JS_STR(val)
  6. Dim TMP_VAL
  7.     TMP_VAL = val
  8.     If Len(TMP_VAL) > 0 Then
  9.         TMP_VAL = Replace(TMP_VAL,chr(34),"&quot;")
  10.         TMP_VAL = Replace(TMP_VAL,"'","`")
  11.         TMP_VAL = Replace(TMP_VAL,"(","[")
  12.         TMP_VAL = Replace(TMP_VAL,")","]")        
  13.     End IF
  14.     FIX_JS_STR = TMP_VAL
  15. END FUNCTION
  16.  
  17.  
  18.  
  19. '// ENCRYPTS STRING SUCH AS PASSWORD
  20. '// Returns encrypted string such as: BTEGE^J] to password
  21. FUNCTION EnCrypt(strCryptThis)
  22.   Dim strChar, iKeyChar, iStringChar, i
  23.   for i = 1 to Len(strCryptThis)
  24.      iKeyChar = Asc(mid("2564218975223456482120840",i,1))
  25.      iStringChar = Asc(mid(strCryptThis,i,1))
  26.      iCryptChar = iKeyChar Xor iStringChar
  27.      strEncrypted =  strEncrypted & Chr(iCryptChar)
  28.   next
  29.   EnCrypt = strEncrypted
  30. END FUNCTION
  31.  
  32. '// DECRYPT STRING SUCH AS PASSWORD
  33. '// Returns decrypted string such as: password to BTEGE^J]
  34. FUNCTION DeCrypt(strEncrypted)
  35. Dim strChar, iKeyChar, iStringChar, i
  36.   for i = 1 to Len(strEncrypted)
  37.      iKeyChar = (Asc(mid("2564218975223456482120840",i,1)))
  38.      iStringChar = Asc(mid(strEncrypted,i,1))
  39.       iDeCryptChar = iKeyChar Xor iStringChar
  40.      strDecrypted =  strDecrypted & Chr(iDeCryptChar)
  41.   next
  42.   DeCrypt = strDecrypted
  43. END FUNCTION
  44.  
  45. PRIVATE FUNCTION APO(val)
  46.     Dim tmpSTR
  47.     tmpSTR = val
  48.     IF NOT tmpSTR = "" THEN
  49.         tmpSTR = Replace(Trim(tmpSTR),chr(34),"&quot;")
  50.         tmpSTR = Replace(Trim(tmpSTR),"'","''")
  51.         tmpSTR = Replace(Trim(tmpSTR),"<","&lt;")
  52.         tmpSTR = Replace(Trim(tmpSTR),">","&gt;")
  53.         IF DB_TO_USE = 3 THEN tmpSTR = Replace(Trim(tmpSTR),"\","\\")
  54.     END IF
  55.     'APO = tmpSTR
  56.     APO = replace(val, "'", "'")    
  57. END FUNCTION
  58.  
  59. PRIVATE FUNCTION APO_LAX(val)
  60.     Dim strRES
  61.     strRES = Replace(Trim(val),"'","''")
  62.     IF DB_TO_USE = 3 THEN strRES = Replace(Trim(strRES),"\","\\")
  63.     'APO_LAX = strRES
  64.     APO_LAX = replace(val, "'", "'")
  65. END FUNCTION
  66.  
  67. PRIVATE FUNCTION APO_INJ(val)
  68.     Dim tmpSTR
  69.     tmpSTR = val
  70.     IF NOT tmpSTR = "" THEN
  71.         tmpSTR = Replace(Trim(tmpSTR),chr(34),"&quot;")
  72.         tmpSTR = Replace(Trim(tmpSTR),"<","&lt;")
  73.         tmpSTR = Replace(Trim(tmpSTR),">","&gt;")
  74.         IF DB_TO_USE = 3 THEN tmpSTR = Replace(Trim(tmpSTR),"\","\\")
  75.     END IF
  76.     'APO_INJ = tmpSTR
  77.     APO_INJ = replace(val, "'", "'")
  78. END FUNCTION
May 11 '07 #1
1 3169
karen987
114 100+
I just want to add something,

in the 3 APO statements above there is a line in each which reads
APO_INJ = replace(val, "'", "'")

I just want to say that it doesn't show on this page, but the second apostrophe in the double quotes actually reads, "ampersand, hash, 39, semicolon"

I had to add this here because if you look at the code, it shows an apostrophe instead of the 4 characters . In the acctual inc_api.asp page, the first set shows an actual apostrope between the double quotes, and the second set shows "apersand, hash, 39 and semicolon"

I think this is a glitch in this forum,

Thanks.
May 11 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.