Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324002

Summary: Formating of JavaScript corrupts source
Product: [WebTools] JSDT Reporter: Terry Denney <terry.hon>
Component: WebAssignee: Ian Tewksbury <itewksbu>
Status: CLOSED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: nsand.dev
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Terry Denney CLA 2010-08-30 13:40:40 EDT
Formating a HTML page with JavaScript having a html tags in a String corrupts the source.
e.g.
alert("<div></div>")
results in 
alert("_$tag</div>")

Reproduce with this simple html and execute "Source > Format"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
	alert("<div></div>")
</script>
</head>
<body>
</html>

As a result the first '<div>' will be replaced with '_$tag'.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
	alert("_$tag</div>")
</script>
</head>
<body>
</html>

Every further execution will change the next tag too, so after two format executions, it will end as:
alert("_$tag_$tag_")
Comment 1 Ian Tewksbury CLA 2010-08-31 08:33:06 EDT

*** This bug has been marked as a duplicate of bug 319855 ***