PRB: Microsoft Scripting Encoder Does Not Encode Nested Scripts

ID: Q243528


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) version 5


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> 


REFERENCES

Microsoft Scripting Technologies
Microsoft Scripting Encoder

Additional query words: VBScript JScript Encoder

Keywords : kbGrpInet kbIE500 kbDSupport
Version : WINDOWS:5
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: November 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.