A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2765 below:

[vf] Attributes with dot cause a VfParseException · Issue #2765 · pmd/pmd · GitHub

Affects PMD Version:

6.27.0

Description:

Visualforce parser throws a ParseException when an attribute contains a dot. In my example, the dot is a valid html attribute and the page renders correctly when used in a Salesforce application.

<table-row keep-together.within-page="always" >

When I modify the keep-together.within-page attribute to something else without the ., the parsing completes successfully.

Digging in a little more, I notice that the error is thrown from classes generated from the grammar in VfParser.jjt. Will add more information when I can narrow down the problem a little more.

Exception Stacktrace:

net.sourceforge.pmd.PMDException: Error while parsing /my/local/sample_component/modifiedTrial.component
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:110)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:89)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:51)
...
Caused by: net.sourceforge.pmd.lang.vf.ast.ParseException: Encountered \" \u003cIN_TAG_ERROR\u003e \". \"\" at line 15, column 37.
Was expecting:
    \"\u003d\" ...\n    
at net.sourceforge.pmd.lang.vf.ast.VfParser.generateParseException(VfParser.java:3154)
at net.sourceforge.pmd.lang.vf.ast.VfParser.jj_consume_token(VfParser.java:3030)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Attribute(VfParser.java:1554)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Element(VfParser.java:1494)
at net.sourceforge.pmd.lang.vf.ast.VfParser.ContentElement(VfParser.java:205)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Content(VfParser.java:165)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Element(VfParser.java:1500)
at net.sourceforge.pmd.lang.vf.ast.VfParser.ContentElement(VfParser.java:205)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Content(VfParser.java:165)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Element(VfParser.java:1500)
at net.sourceforge.pmd.lang.vf.ast.VfParser.ContentElement(VfParser.java:205)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Content(VfParser.java:165)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Element(VfParser.java:1500)
at net.sourceforge.pmd.lang.vf.ast.VfParser.ContentElement(VfParser.java:205)
at net.sourceforge.pmd.lang.vf.ast.VfParser.Content(VfParser.java:165)
at net.sourceforge.pmd.lang.vf.ast.VfParser.CompilationUnit(VfParser.java:58)
at net.sourceforge.pmd.lang.vf.VfParser.parse(VfParser.java:47)
at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:121)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:185)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:107)
... 10 more

Code Sample demonstrating the issue:

<apex:component access="global" id="myDataTable" controller="MyTestController">
    <apex:attribute name="dataMap" type="List" description="A sample data set"/>
    <apex:attribute name="tableWidth" type="String" description="Width of the generated table."/>
    <apex:attribute name="tableStart" type="String" description="Start position of the generated table."/>
    <apex:attribute name="tableType" type="String" description="Type of table."/>
    <apex:attribute name="fontFamily" access="global" type="String" description="Default font family"/>
    <apex:attribute name="fontSize" access="global" type="Decimal" description="Default font size"/>
    <apex:attribute name="textColor" access="global" type="String" description="Default text color"/>
    <table width="{!tableWidth}px" start-indent="{!tableStart}px">
        <table-column column-width="40%"/>
        <table-column column-width="18%"/>
        <table-column column-width="18%"/>
        <table-column column-width="24%"/>
        <table-header start-indent="0px">
            <table-row keep-together.within-page="always" >
                <table-cell number-columns-spanned="4"
                            border-after-width="0px" border-after-style="solid" border-after-color="white"
                            border-left-width="0px" border-left-style="solid" border-left-color="white"
                            border-right-width="0px" border-right-style="solid" border-right-color="white" padding-bottom="5px">
                    <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="left" font-weight="bold">
                        {!tableType}
                    </block>
                </table-cell>
            </table-row>
            <table-row>
                <table-cell
                        border-after-width="1px" border-after-style="solid" border-after-color="black"
                        border-left-width="0px" border-left-style="solid" border-left-color="white"
                        border-right-width="0px" border-right-style="solid" border-right-color="white">
                    <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="left">{!$Label.lbl_tier}</block>
                </table-cell>
                <table-cell
                        border-after-width="1px" border-after-style="solid" border-after-color="black"
                        border-left-width="0px" border-left-style="solid" border-left-color="white"
                        border-right-width="0px" border-right-style="solid" border-right-color="white"
                        padding-right="2px">
                    <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="left">{!$Label.lbl_lower}</block>
                </table-cell>
                <table-cell
                        border-after-width="1px" border-after-style="solid" border-after-color="black"
                        border-left-width="0px" border-left-style="solid" border-left-color="white"
                        border-right-width="0px" border-right-style="solid" border-right-color="white"
                        padding-right="2px">
                    <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="left">{!$Label.lbl_upper}</block>
                </table-cell>
                <table-cell
                        border-after-width="1px" border-after-style="solid" border-after-color="black"
                        border-left-width="0px" border-left-style="solid" border-left-color="white"
                        border-right-width="0px" border-right-style="solid" border-right-color="white">
                    <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="right">{!$Label.lbl_myData}</block>
                </table-cell>
            </table-row>
        </table-header>
        <table-body start-indent="0px">
            <apex:repeat var="myDataTier" value="{!dataMap}">
                <table-row line-height="10pt">
                    <apex:repeat var="myDataCell" value="{!myDataTier}" rows="3">
                        <table-cell border-after-width="0px" border-after-style="solid" border-after-color="white"
                                    border-left-width="0px" border-left-style="solid" border-left-color="white"
                                    border-right-width="0px" border-right-style="solid" border-right-color="white" padding-top="1px" padding-bottom="1px">
                            <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="left" wrap-option="wrap">
                                <apex:outputText value="{!myDataCell}" escape="false"/>
                            </block>
                        </table-cell>
                    </apex:repeat>
                    <apex:repeat var="myDataCell" value="{!myDataTier}" first="3" rows="3">
                        <table-cell border-after-width="0px" border-after-style="solid" border-after-color="white"
                                    border-left-width="0px" border-left-style="solid" border-left-color="white"
                                    border-right-width="0px" border-right-style="solid" border-right-color="white" padding-top="1px" padding-bottom="1px">
                            <block font-size="{!fontSize}pt" font-family="{!fontFamily}" color="#{!textColor}" text-align="right" wrap-option="wrap">
                                <apex:outputText value="{!myDataCell}" escape="false"/>
                            </block>
                        </table-cell>
                    </apex:repeat>
                </table-row>
            </apex:repeat>
        </table-body>
    </table>
</apex:component>

Steps to reproduce:

  1. Copy code sample into a new file (For example: /my/local/sample_component/modifiedTrial.component)
  2. Run PMD with a ruleset containing all VF rules:
pmd -d "/my/local/sample_component/modifiedTrial.component" -f json -R /my/local/pmd_trials/rule-allvf.xml
  1. Notice that a PMDException is thrown:
PMDException: Error while parsing /my/local/sample_component/modifiedTrial.component

Running PMD through: CLI


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4