Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 400026

Summary: Add a parser util to support detecting a valid and safe URL from a given string.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: 2.0 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 398905    

Description libing wang CLA 2013-02-05 16:35:18 EST
To fix bug 398905, by a given string, we need a kind of generic parser to detect if valid and safe URLs occur in the string. Multiple occurrence is possible.

The parsing function will generate an array of mixed segments of plain text and valid URL strings.

The intended valid URL has to be enclosed by "[" and "]" inside the string.

E.g. : "This is a valid URL [http://abc.com:8080/params=foo]"
Comment 1 libing wang CLA 2013-02-05 16:43:19 EST
fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=4e7caf911964f6758108b0673e1538d0f8238008.

Added some unit tests on the new function. Works ok.

Also tried to consume it in a prototype of bug 398905 and it works fine. We could see the valid URL to be rendered as a link with all other segments rendered as plain text.
Comment 2 libing wang CLA 2013-02-06 17:48:34 EST
Pushed another commit to use URL-shim for detecting a real URL before asking pageUtil.validateURLScheme().


 if(new URL(the string inside the []).href){
  //URL detected.
} 

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=96357f8db017b2436ce2a886fd42e4a991fb86a3