This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 167856 - Mixed JS/PHP highlighting bug
Summary: Mixed JS/PHP highlighting bug
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Petr Hejl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-30 08:36 UTC by marcusson
Modified: 2012-09-14 02:11 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marcusson 2009-06-30 08:36:54 UTC
NetBeans reports a syntax error (unterminated string literal) for the following (valid) JavaScript/PHP construct.

<script type="text/javascript">
var sessionId ="<?php echo $sid; ?>
";
</script>

For static parsing the code seems invalid. But if you run the code, you will find that the EOL characters after ?> are
ignored.

So the output of the script above is the following valid code:
<script type="text/javascript">
var sessionId ="1234";
</script>

While I personally won't wright code like this, the output is actually produced by the Smarty Template Engine, which
always adds a line-break after each delimiter. As a result NetBeans reports many errors within files inside Smarty's
template cache directory.

Workaround:
- create a custom filter to tell NetBeans to ignore Smarty's compile cache
Comment 1 Marek Fukala 2010-05-18 07:50:38 UTC
The problem here is not the templating language, but the endline after the <? section ?> and the closing quote. It these are at the same line, the editor doesn't complain.

<script type="text/javascript">
var sessionId ="<?php echo $sid; ?>";
</script>

is lexed and parsed w/o problems.
Comment 2 marcusson 2010-05-18 19:29:46 UTC
Yes, you are right. That's what I said. The parser should be aware that any new-line after a closing ?> must be ignored.

So this code:
var sessionId ="<?php echo $sid; ?>
";

And this code:
var sessionId ="<?php echo $sid; ?>";

Are perfectly the same and should be treated equally.

Reason (long story): This (strange) rule has something to do with unix-style files, that always end with a single new-line character, thus conflicting with the requirement to close the PHP-tag. Ergo: the developers set up a rule, that any new-line directly following a closing PHP-tag will be removed by PHP automatically and thus must be ignored.

Some libraries and editors make extensive use of this rule (e.g. the popular Smarty template engine). Thus resulting in hundreds of irrelevant (and obviously wrong) error messages cluttering up NetBeans' task-list.

If this is the first thing you recognize as a developer when opening your project in NetBeans for the first time, it could be a real show-stopper.
Comment 3 Petr Pisl 2011-10-17 15:37:43 UTC
Reproducible in NB 7.1
Comment 4 Petr Hejl 2012-09-12 18:53:53 UTC
Fixed in web-main 5f47746be723.
Comment 5 Quality Engineering 2012-09-14 02:11:34 UTC
Integrated into 'main-golden', will be available in build *201209140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5f47746be723
User: Petr Hejl <phejl@netbeans.org>
Log: #167856 - Mixed JS/PHP highlighting bug