sparser icon indicating copy to clipboard operation
sparser copied to clipboard

Frontend script files with doctype are interpreted as HTML

Open stevenzeck opened this issue 7 years ago • 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.

stevenzeck avatar Jul 13 '18 14:07 stevenzeck

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.

prettydiff avatar Jul 16 '18 11:07 prettydiff

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>

stevenzeck avatar Jul 17 '18 14:07 stevenzeck

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.

prettydiff avatar Jul 17 '18 21:07 prettydiff