php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3077 ASP tags aren't recognized
Submitted: 1999-12-31 20:36 UTC Modified: 2001-01-30 03:41 UTC
From: djm at web dot us dot uu dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: BSDI BSD/OS 4.0.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: djm at web dot us dot uu dot net
New email:
PHP Version: OS:

 

 [1999-12-31 20:36 UTC] djm at web dot us dot uu dot net
I'm having a lex-related problem.  I compiled PHP4.0b3 as a DSO in apache 1.3.9.
ASP-style tags and the code in them are displayed in the browser instead of being parsed, even though the httpd.conf contains
php_flag asp_tags On
phpinfo() confirms that the Local Value of asp_tags flag is On.
All of the other tags styles are parsed correctly, but stuff like 
<% echo ("You may optionally use ASP-style tags"); $variable = "boo"; %>
<%= $variable; # This is a shortcut for "<%echo .." %>
gets sent verbatim to the browser.

I've looked through zend-scanner.l and can't find anything wrong.  I tried removing the conditionals on asp_tags there, and changing the <% and %> to <@ and @>
in that file and in my PHP script to see if % was causing trouble, but neither of those approaches worked.  I also tried removing optimization when compiling
zend-scanner.c.  No effect.
This is weird.

I was able to confirm that I was getting my changed scanner by breaking the rules for identifying the short SGML tags.  I found that there's a missing dependency because I had to
rm libzend/libzend.la
in order to force the php module to be rebuilt after the scanner changed.

I'm using PHP compiled as a DSO with apache 1.3.9.
Compiled using flex version 2.5.4 and gcc 2.7.2.1.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-12-31 21:30 UTC] djm at web dot us dot uu dot net
Ok, I have a workaround, and a related bug fix.
I think the first time I missed an occurrence of asp_tags in zend-scanner.l.
This time I did a global search and replace, and ASP tags started working.  phpinfo() still shows that I set the asp_tags flag On, so I don't understand why this made a difference.

Once I got that working, I found a clearer bug: the scanner doesn't support one-line comments in ASP tags.
Even though they're shown in the ASP tags example at
http://www.php.net/manual/language.basic-syntax.php3

Here are the changes I made to get it working:

--- zend-scanner.l      1999/12/30 22:31:18     1.1.1.2
+++ zend-scanner.l      2000/01/01 02:24:16
@@ -1031,7 +1031,7 @@
 
 
 <INITIAL>"<%="|"<?=" {
-       if ((yytext[1]=='%' && CG(asp_tags))
+       if ((yytext[1]=='%' && CG(short_tags))
                || (yytext[1]=='?' && CG(short_tags))) {
                zendlval->value.str.val = yytext; /* no copying - intentional */
                zendlval->value.str.len = yyleng;
@@ -1048,7 +1048,7 @@
 
 
 <INITIAL>"<%" {
-       if (CG(asp_tags)) {
+       if (CG(short_tags)) {
                zendlval->value.str.val = yytext; /* no copying - intentional */
                zendlval->value.str.len = yyleng;
                zendlval->type = IS_STRING;
@@ -1111,7 +1111,7 @@
 }
 
 
-<ST_IN_SCRIPTING>([#]|"//")([^\n\r?]|"?"[^>\n\r])*("?\n"|"?\r\n")? { /* eat one line comments */
+<ST_IN_SCRIPTING>([#]|"//")([^\n\r?%]|[?%][^>\n\r])*([?%]"\n"|[?%]"\r\n")? { /* eat one line comments */
        HANDLE_NEWLINE(yytext[yyleng-1]);
        return T_COMMENT;
 }
@@ -1151,7 +1151,7 @@
        zendlval->value.str.len = yyleng;
        zendlval->type = IS_STRING;
        HANDLE_NEWLINES(yytext,yyleng);
-       if (CG(asp_tags)) {
+       if (CG(short_tags)) {
                BEGIN(INITIAL);
                return T_CLOSE_TAG;  /* implicit ';' at php-end tag */
        } else {

 [2000-06-06 21:33 UTC] andi at cvs dot php dot net
This should be fixed in the latest CVS.
Please grab it or in about 24 hours get the latest snapshot from snaps.php.net
 [2000-10-18 19:16 UTC] djm at web dot us dot uu dot net
This is partly fixed in 4.0.3pl1.  ASP tags are recognized, but they still don't work with single-line comments.  You still need to apply the patch I submitted for the "eat one line comments" line of the lexer.  All it does is replace "?" with "[?%]" in the regexp so that it works for <% as well as <?.  Of course, if you have asp_tags off, you might not want that to happen... I'm not sure what's best in that case.  

Here is a valid PHP script that gets a parse error from 4.0.3pl1.

<html><head><title>comments test</title></head>
<body>
<hr>
<?php echo("Hash comments work\n"); $variable="blah"; # never mind this stuff ?>
<?= $variable; # This is a shortcut for "<?echo .." ?>
<p>
<% echo ("You may optionally use ASP-style tags"); $variable = "boo"; %>
<% echo (" (if they work)"); # this should be ignored also %>
<%= $variable; # This is a shortcut for "<%echo .." %>
<hr>
<? phpinfo() ?>
</body>
</html>

 [2001-01-06 00:55 UTC] cynic@php.net
Could you please check if this exists in 4.0.4 or latest CVS? ASP-style tags and single line comments work for me(TM).
 [2001-01-30 03:41 UTC] sniper@php.net
No feedback. And should be fixed.

--Jani
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 14:01:28 2025 UTC