Solved

Functios that removes text gives error Out of string space asp

Posted on 2009-03-30
8
897 Views
Last Modified: 2012-05-06
The function I have below is supposed to remove scripts form a web page.

It works ok but if a page is vero large it returns an error:

Microsoft VBScript runtime error '800a000e'

Out of string space: 'mid'

/gt/awx.asp, line ###

I realize the server ihas run out of string memory...

How can I solve this?



Function StripScript(HtmlString)

do while true

if instr(HtmlString,"<script")=0 then

exit do

else

rt=instr(HtmlString,"<script")-1

lt=instr(HtmlString,"</script>")+9

rts=left(HtmlString,rt)

lts=mid(HtmlString,lt)

HtmlString=rts+lts

end if

loop

Open in new window

0
Comment
Question by:robrodp
  • 4
  • 4
8 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 24021923
I'm a little confused. If you wrote the page wouldn't you know that it had scripts and just not put them in?

Or is this for FORM based user input?  In other words why else would you need to dynamically remove the script at "run time"?

Do you just have a bunch of files that you want to "descript"? If so a little program in some language would probably work better.

Is it such that you should be parsing a file and writing to another file?

Please provide more info as to what you are trying to do.
0
 

Author Comment

by:robrodp
ID: 24022057
In asp I download a page. My clients tell me which. ANd on the fly I strip all the script code. As muc as possible.  The function works fine excpet for loarge pages
0
 
LVL 25

Expert Comment

by:SStory
ID: 24022748
OK. if I understand correctly,  a client submits a HTML page to your asp page and you are doing back end processing on it.  I think you still may want to parse the file submitted to another file and use the resulting file.

Obviously there is too much to process.  How about a different strategy....
Since you know the begin and end of the script, replace all of that with ""
It should presumably be a lot less text
0
 

Author Comment

by:robrodp
ID: 24022779
I know the script start with "<script" and ends with "</script>"

How can I vhange al that to "". In a way that is what the function does.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 24022794
rt=instr(HtmlString,"<script")-1
lt=instr(HtmlString,"</script>")+9
Replace(HtmlString, Mid(HtmlString,rt,lt-rt),"")

'not sure if the above works in ASP, but if so, it should replace the entire <script></script> region and leave 'you with the page

I may be off by one on the lt-rt thing, if so adjust it
0
 

Author Closing Comment

by:robrodp
ID: 31564452
It does work and I guess it uses less string memory thx
0
 
LVL 25

Expert Comment

by:SStory
ID: 24022891
You are welcome. The only problem would be on pages with tons of scripting inside of the same <script></script> tags...which hopefully won't be a problem.

If you run into the problem again, you may want to consider the file parsing option.  Take the user's input or file (one way or another get it into a file), open it for input, read until you hit <script>, writing each line to the new output file...read until you hit </script>, not writing anything, then repeat the process until EOF.  close both files, delete the original and you should have it....this avoids string memory issues, and also the fact that if you have many people hitting the page at the same time you may run out of memory.  1000 people doing this, and you storing their pages in memory at the same time to manipulate would take a lot of memory.  Using the file method would probably be better in that case...Of course you'd need to come up with unique filenames to avoid naming collisions...using the filename plus the Session ID might be one option.
0
 

Author Comment

by:robrodp
ID: 24023025
Why didn't I think of thar before?

Thx

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do i Properly Convert Date time String in C# 29 66
two submit buttons one form 15 75
Using querystring in a hyperlink 3 46
is this a cms? 8 34
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now