Unibeautify/sparser

Frontend script files with doctype are interpreted as HTML

Opened this issue · 3 comments

Take the following PHP code sample:

<!DOCTYPE html>
<html>
<body>

<?php  
$x = 1;
 
while($x <= 5) {
  echo "The number is: $x <br>";
  $x++;
} 
?>  

</body>
</html>

The framework interprets this as an HTML file instead of PHP. It you remove the doctype, it interprets it as PHP as expected. Furthermore, the opening and closing and tags are parsed as script instead of markup.

I am not properly supporting PHP at this time, so I am marking this as an enhancement. If full support were present then this would be an HTML document containing a PHP tag, and the PHP tag portion would be parsed separately from the HTML as PHP instead of JavaScript.

I am not properly supporting PHP at this time, so I am marking this as an enhancement

Fair enough. Which languages are supported? It looks like any frontend non-JS scripting language (JSP, PHP, etc) has this issue. This piece of JSP does the same thing:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Home Page</title>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
</head>
<body>
<c:if test = "${exception ne null}">
   <p>Exception is : ${exception} <br>
   Exception Message: ${exception.message}</p>
</c:if>
</body>
</html>

I am really faking it a lot with a generic script parser. In most cases this isn't an issue, but I need to perform an audit and write a bunch more test cases. This will take time.