Microsoft KB Archive/243528

= PRB: Microsoft Scripting Encoder Does Not Encode Nested Scripts =

Article ID: 243528

Article Last Modified on 7/20/2001

-

APPLIES TO


 * Microsoft Internet Explorer 5.0

-



This article was previously published under Q243528



SYMPTOMS
An Active Server Pages (ASP) page encoded by using Microsoft Scripting Encoder 1.0 gives a scripting error, whereas the un-encoded version works fine.



CAUSE
The Microsoft Scripting Encoder does not handle conditional inclusion of the source code correctly. If there is any conditional inclusion of client side and server side code, the encrypted code might be incorrect and give scripting errors.



RESOLUTION
Do not include conditional code that involves the nesting of client-side and server-side code. The entire script block needs to be complete when it gets handed to the encoder.



STATUS
This behavior is by design.



MORE INFORMATION
The following code demonstrates the problem. To reproduce the problem, copy the following ASP code and save it as Source.asp. Execute the following inline commands sequentially, and then run the Encoded.asp: screnc.exe source.asp output.asp screnc.exe /e html output.asp encoded.asp

<%@ LANGUAGE="VBSCRIPT" %> <%option explicit%> <%Call Main%> <% Sub Main Dim SomeVariable SomeVariable = True %> Function SomeFunction <% if SomeVariable = True then %> ' Do Something <% end if %> End Function Encoder does not work? <%End Sub%> The files Source.asp and Output.asp work fine, but Encoded.asp does not.

Changing the above ASP code into the following format overcomes this problem: <%@ LANGUAGE="VBSCRIPT" %> <%option explicit%> <%Call Main%> <% Sub Main Dim SomeVariable SomeVariable = True %> <% if SomeVariable = True then %> Function SomeFunction ' Do Something End Function <% Else %> Function SomeFunction ' Do Something Else End Function <% End If %> Yes, Encoder does work! <%End Sub%>

