Microsoft KB Archive/243528

From BetaArchive Wiki
Knowledge Base


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%>
<html>
<% Sub Main
Dim SomeVariable
SomeVariable = True %>
<script language=vbscript>
Function SomeFunction()
<% if SomeVariable = True then %>
    ' Do Something
<% end if %>
End Function
</script>
<body>
Encoder does not work?
</body>
<%End Sub%>
</html>
                

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%>
<html>
<% Sub Main
Dim SomeVariable
SomeVariable = True %>
<% if SomeVariable = True then %>
<script language=vbscript>
Function SomeFunction()
    ' Do Something
End Function
</script>
<% Else %>
<script language=vbscript>
Function SomeFunction()
    ' Do Something Else
End Function
</script>
<% End If %>
<body>
Yes, Encoder does work!
</body>
<%End Sub%>
</html>
                


Additional query words: VBScript JScript Encoder

Keywords: kbprb KB243528