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 268258

Summary: WebUtils.resolveToReference() - isn't check for '#' needed there?
Product: web Reporter: NukemBy
Component: HTML EditorAssignee: Milutin Kristofic <mkristofic>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: Dev   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description NukemBy 2016-09-28 21:10:41 UTC
Most probably I've selected wrong component, but I hope issue will be redirected to right people.

In this line ...

    http://hg.netbeans.org/main/file/ef35591e2d0f/web.common/src/org/netbeans/modules/web/common/api/WebUtils.java#l137

    FileObject resolvedFileObject = parent.getFileObject(URLDecoder.decode(importedFileName, "UTF-8")); //NOI18N

... there is a file path being constructed and resolved from relative URL (stored in variable `importedFileName`) in parent HTML file. In general URL may contain hash part, which is not mapped into file system - i.e. presence of '#' will, typically, always lead to null result.

I suspect some additional verification is needed there

    String fileUrl = URLDecoder.decode(importedFileName, "UTF-8");  //NOI18N
    int posHash = fileUrl.indexOf('#');

    if( posHash != -1 )
        fileUrl = fileUrl.substring(0, posHash);

    FileObject resolvedFileObject = parent.getFileObject(fileUrl);
Comment 1 Milutin Kristofic 2016-10-03 15:26:41 UTC
Thank you, it was inconsistent since we remove query part but not fragment part. Fixed here : http://hg.netbeans.org/jet-main/rev/7be60ce369ec
Comment 2 Quality Engineering 2016-10-04 01:54:15 UTC
Integrated into 'main-silver', will be available in build *201610040002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/7be60ce369ec
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #268258 - WebUtils.resolveToReference() - isn't check for '#' needed there?