Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PARSE_ERROR when concatenating strings with single quotes #359

Closed
mpaluchowski opened this issue Jul 18, 2017 · 8 comments
Closed

PARSE_ERROR when concatenating strings with single quotes #359

mpaluchowski opened this issue Jul 18, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@mpaluchowski
Copy link
Contributor

Scanning the following code causes a PARSE_ERROR:

<cfcomponent>
  <cffunction name="foo">
    <cfinvoke component="SomeComponent" returnvariable="baz" method="baz">
	  <cfinvokeargument name="x" value="#someVar# & '_' & #someOtherVar#">
    </cfinvoke>
  </cffunction>
</cfcomponent>

in XML:

<issue severity="ERROR" id="PARSE_ERROR" message="PARSE_ERROR" category="CFLint" abbrev="PE">
  <location file="C:\Inbox\cflint-test\.\test.cfc" fileName="test.cfc" function="" column="0" line="4" message="Unable to parse" variable="_">
    <Expression><![CDATA[<cfinvokeargument name="x" value="#someVar# & '_' & #someOtherVar#">]]></Expression>
  </location>
</issue>

and in the console:

line 1:14 no viable alternative at input ''#someVar# & '_'

Seems to be triggered by the single quotes ' in the middle of the concatenated string, because when I replace the <cfinvokeargument> line with:

<cfinvokeargument name="x" value='#someVar# & "_" & #someOtherVar#'>

the error disappears.

@mpaluchowski
Copy link
Contributor Author

Seems to be a general problem with single quotes, not just in <cfinvoke>. The following code triggers similar errors:

<cfcomponent>
  <cffunction name="foo">
    <cfsavecontent variable="bar">
	  <cfoutput>
        <span onMouseOver="baz('#id##criteriaName#',true)"></span>
      </cfoutput>
    </cfsavecontent>
  </cffunction>
</cfcomponent>

in the console:

line 1:6 no viable alternative at input ''baz('#'

ryaneberly added a commit that referenced this issue Jul 21, 2017
@mpaluchowski
Copy link
Contributor Author

Much better now, but there are still cases where this is triggered:

<cffile action="write" file="#LCase(local.destination)##rc.attachment_cvhtml_filename#.html" charset="utf-8" output='<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /></head><body>#local.stepCV#</body>'>

because of the value of output provided in single quotes. Removing the output attribute also gets rid of the parse error. Here's the console error:

line 1:28 no viable alternative at input '"<!DOCTYPE html><html lang="en'

@mpaluchowski
Copy link
Contributor Author

More lines causing PARSE_ERROR:

<cfset import(Event, local.uploadPathBild&file.serverfile)>
<cfloop list="AdminUser_ID,AdminGroup_ID,AdminPriv" index="key">
</cfloop>

@mpaluchowski
Copy link
Contributor Author

Also, there are PARSE_ERRORs reported for # signs outside of <cfoutput> statements, ie:

<div style="background-color:#8d9bdc;"><cfoutput>#foo#</cfoutput></div>

will cause an error:

line 1:20 no viable alternative at input '"background-color:#8d9bdc'

@ryaneberly
Copy link
Contributor

Great examples. thanks much @mpaluchowski . We're almost there.

ryaneberly added a commit that referenced this issue Jul 22, 2017
ryaneberly added a commit that referenced this issue Jul 22, 2017
@ryaneberly
Copy link
Contributor

All are fixed except the import keyword one
cfparser/cfparser#82

That will have to wait til the next version of cfparser.

@ryaneberly
Copy link
Contributor

Need to use cfmlparser.parseCFMLExpression() in next version of cfparser

@ryaneberly ryaneberly added this to the 1.2.1 milestone Jul 30, 2017
@ryaneberly ryaneberly self-assigned this Aug 6, 2017
ryaneberly added a commit that referenced this issue Aug 9, 2017
@ryaneberly
Copy link
Contributor

@mpaluchowski The last parsing issue is working.

ryaneberly added a commit that referenced this issue Aug 10, 2017
* Remove dependency copying (#376)

There doesn't seem to be a reason to have this phase. Perhaps there was
one before? All the required dependencies are added to the final JAR by
the `maven-shade-plugin` in the `package` phase anyway. This dependency
copying just seems like a waste of time.

* Add .editorconfig

Provides common whitespace settings for all editors. Supported out of
the box in some IDE's (like IntelliJ IDEA) and all others have
appropriate plugins.

*  Added .cflintrc schema and output schemas for JSON and XML. Tweaked README. (#377)

Added .cflintrc schema and output schemas for JSON and XML. Tweaked README.

* support autochange

* #382

* Align Gradle dependencies with Maven ones (#378)

Define the same set (and scopes) of dependencies for Gradle builds as we
have now in Maven's `pom.xml`.

* Added some context to the changelog for 1.2.0 and removed a lot of "##### no issues" items that were added to the list.

* Changed setting for auto-adding a final new line, that screws up expected files for tests.

* #383 Changed code, test, README with the output sample and JSON schema.

* Update timestamp type in result schemas

* #385 Two small modifications to HTML report

* Changed build versions to 1.2.1-SNAPSHOT in dev branch and change documentation to 1.2.1 in dev branch.

* 390 Add Implementation-Version to MANIFEST

Configures the Maven and Gradle builds to include
`Implementation-Version` in the MANIFEST.MF file, which can then be read
by the application and displayed to the user.

* #385 - Further HTML report improvements

* #390 - Adapting new way to grab version string

* #390 - Hopefully fixing Gradle build

* #390 - Review changes

* #396 fixed

* Update README.md

Explains how to pass multiple arguments in the command line in Windows Powershell and fixes a typo.

Fixes #400

* Update CODE_OF_CONDUCT.md

* #380 fixed

* Added VS Code info. Some cleanup.

* use cfparser 2.4.11

* #408

* #373

* #367

* #367

* add sonatype repo

* merged master

* cfparser 2.5.0

* Added test for #359 showing parsing error gone with cfparser 2.5.0

* #359 use parseCFMLExpression

* fix tests

* test for #346

* #413

* fix test

* fix javadoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants