473,581 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem showing apostrophe and double quotes, on web page

114 New Member
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.as p" 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 3421
karen987
114 New Member
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

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

Similar topics

13
11380
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices Restaurant" etc. automatically and programmatically during data entry? This would eliminate my concatinated strings from producing errors when I...
12
9623
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" & Chr(34) & PopUpWindowTitle & Chr(34) & ", " & Chr(34) & CurrentEventDetails & ")" strTemp += "<BR><A HREF='#' onClick='" & PopupLink & "'>" & EventName &...
4
2207
by: AZNewsh | last post by:
I am storing HTML in an oracle database, this is loaded from a textbox in a webpage, I convert ' to ' ' using the code below: foo.Replace("'", "''").Replace("&", "'||'&'||'") this works just fine, then when I retrieve the text from the database and display it in a webpage, I convert it back using: objdr.Item("foo").Replace("''",...
3
6813
by: Alan Mailer | last post by:
Ok, I've looked for an answer for this, because I'm sure it's been asked a thousand times... but no luck... so here goes. Imagine I want to create a NodeList based on an XPath statement. The 'query' portion of that statement wants to search for the following value: Joe's Garage ....now please note the APOSTROPHE in the above string.
0
7808
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5683
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.