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

Core: PrimeFaces.resources.getFacesResource() RegExp issue #4850

Closed
melloware opened this issue May 30, 2019 · 0 comments

Comments

Projects
None yet
3 participants
@melloware
Copy link
Contributor

commented May 30, 2019

Found this error randomly in production.

var appUrl = pf.resources.getFacesResource('documentviewer/pdf.viewer.js', pfext.RESOURCE_LIBRARY, pfext.VERSION);

Because we use OmniFaces Resource Handler the URL can be something crazy like...

https://test.com/javax.faces.resource/eNp9kGEOwiAMhU-08X_n8AKMVS0rFCkkLvHwjsASg870x3v9-kJo2Xm8agMy8eFGK68Q0UHl9pEhbqpKNzMc4Qu5wB58-vvOECjf0HeZAZ4JvCB7mYRwAc5JHeY8-pOex2dis2ZUTc-DpLfygSrdNndOK2yqSjfDhcCxx8RRffiSsqKCdcN-pB1W0A4ziolMdOFGF532mglaz1qwLPUGmz-thg.js.jsf?ln=omnifaces.combined&v=1559234437000

We noticed intermittently the getFacesResource was not generating the correct URL. Trace the bug to a Regular Expression problem. Because the above URL has a "js" in the middle of it it was not parsing correctly.

Current Regex:

var scriptRegex = new RegExp('\/?' + PrimeFaces.RESOURCE_IDENTIFIER + '(\/|=)(.*?)\.js');

Correct Regex to escape and capture correctly. using \

var scriptRegex = new RegExp('\\/?' + PrimeFaces.RESOURCE_IDENTIFIER + '(\\/|=)(.*?)\\.js');

Submitting a PR.

tandraschko added a commit that referenced this issue May 30, 2019

Merge pull request #4851 from melloware/PF4850
Fix #4850: Core getResourceScriptName RegExp escaping fix.

@tandraschko tandraschko added the defect label May 30, 2019

@tandraschko tandraschko added this to the 7.1 milestone May 30, 2019

@mertsincan mertsincan added the 7.0.4 label May 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.