0

We are getting VfUnescapeEl error in our sfdx report on the following line :

<a href="{!LEFT($CurrentPage.URL,FIND('/',$CurrentPage.URL,9))}{{x.Id}}">...</a>

here, x.id will be in alphanumeric form, just simple text.

Have tried putting JSENCODE in the following ways :

<a href="{!JSENCODE(LEFT($CurrentPage.URL,FIND('/',$CurrentPage.URL,9))}{{x.Id}}">...</a>

<a href="{!LEFT(JSENCODE($CurrentPage.URL,FIND('/',$CurrentPage.URL,9)))}{{x.Id}}">...</a>

<a href="{!LEFT($CurrentPage.URL,FIND(JSENCODE('/'),$CurrentPage.URL,9))}{{x.Id}}">...</a>

But none of them seems to work and pmd still gives the error.

Please suggest how can we resolve this error.

1 Answer 1

0

While this is likely a false positive, I suggest it is because PMD doesn't know that x.Id is always an ID value. Try:

<a href="{!LEFT($CurrentPage.URL, FIND('/',$CurrentPage.URL, 9))}{!URLENCODE(x.Id)}">...</a>

BTW, you could probably do this without two separate expressions just using the "&" concatenation operator. I'm also thinking you should be using a URLFOR variant.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .