@@ -1417,35 +1417,54 @@ private boolean isFollowedByURLPattern() {
14171417 }
14181418
14191419 // Parses a complete URL reference starting from current position
1420- private Object parseURLReference () throws InvalidInputException {
1420+ private Object parseURLReference (boolean httpFlag ) throws InvalidInputException {
1421+ // httpFlag is used to check wheather URL contains http or not
14211422 StringBuilder urlBuilder = new StringBuilder ();
14221423 int firstTokenStartPos = this .scanner .startPosition ;
14231424 //start with the current identifier
14241425 if (this .currentTokenType == TerminalToken .TokenNameIdentifier ) {
14251426 urlBuilder .append (this .scanner .getCurrentTokenSource ());
14261427 consumeToken ();
14271428 }
1429+ char [] fullURL ;
1430+ int pos ;
1431+ if (httpFlag ) {
1432+ // Add :
1433+ TerminalToken token1 = readTokenSafely ();
1434+ if (token1 == TerminalToken .TokenNameCOLON ) {
1435+ urlBuilder .append (this .scanner .getCurrentTokenSource ());
1436+ consumeToken ();
1437+ }
14281438
1429- // Add :
1430- TerminalToken token1 = readTokenSafely ();
1431- if (token1 == TerminalToken .TokenNameCOLON ) {
1432- urlBuilder .append (this .scanner .getCurrentTokenSource ());
1433- consumeToken ();
1434- }
1439+ pos = this .scanner .getCurrentTokenEndPosition () + 1 ;
1440+ char c ;
1441+ while (pos < this .source .length ) {
1442+ c = (this .source [pos ] == ')' ) ? this .source [pos ] : readChar ();
1443+
1444+ if (c == ':' ) continue ;
1445+ if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '*' || c == ')' || c == '(' || c == '[' || c == ']' ) {
1446+ break ;
1447+ }
1448+ urlBuilder .append (c );
1449+ pos ++;
1450+ }
1451+ fullURL = urlBuilder .toString ().toCharArray ();
1452+ } else {
14351453
1436- int pos = this .scanner .getCurrentTokenEndPosition () + 1 ;
1437- char c ;
1438- while (pos < this .source .length ) {
1439- c = (this .source [pos ] == ')' ) ? this .source [pos ] : readChar ();
1454+ //process the second token
1455+ TerminalToken token1 = readTokenSafely ();
1456+ if (token1 == TerminalToken .TokenNameDOT ) {
1457+ urlBuilder .append (this .scanner .getCurrentTokenSource ());
1458+ consumeToken ();
1459+ }
14401460
1441- if ( c == ':' ) continue ;
1442- if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '*' || c == ')' || c == '(' || c == '[' || c == ']' ) {
1443- break ;
1444- }
1445- urlBuilder . append ( c ) ;
1446- pos ++ ;
1461+ TerminalToken token2 = readTokenSafely () ;
1462+ if (token2 == TerminalToken . TokenNameIdentifier ) {
1463+ urlBuilder . append ( this . scanner . getCurrentTokenSource ()) ;
1464+ }
1465+ pos = this . scanner . getCurrentTokenEndPosition () + 1 ;
1466+ fullURL = urlBuilder . toString (). toCharArray () ;
14471467 }
1448- char [] fullURL = urlBuilder .toString ().toCharArray ();
14491468 this .identifierPtr = 0 ;
14501469 this .identifierStack [this .identifierPtr ] = fullURL ;
14511470 this .identifierPositionStack [this .identifierPtr ] = (((long ) firstTokenStartPos ) << 32 ) + (pos - 1 );
@@ -1454,7 +1473,8 @@ private Object parseURLReference() throws InvalidInputException {
14541473 }
14551474
14561475 // Ensure the markdown URL bracket syntax follows []() or [][]
1457- private void checkMarkdownLinkSyntaxValid (int currStartPos ) {
1476+ private void checkMarkdownLinkSyntaxValid (int currStartPos , boolean httpFlag ) {
1477+ // httpFlag is used to check wheather URL contains http or not
14581478 char secondBracket = this .source [currStartPos - 2 ];
14591479 char thirdBracket = this .source [currStartPos - 1 ];
14601480
@@ -1573,15 +1593,23 @@ else if (this.tagValue == TAG_VALUE_VALUE) {
15731593 case TokenNameUNDERSCORE :
15741594 case TokenNameIdentifier :
15751595 char [] identifier = this .scanner .getCurrentIdentifierSource ();
1576- if (isURLScheme (identifier )) {
1577- if (isFollowedByURLPattern ()) {
1578- if (typeRef == null ) {
1579- int currStartPos = this .scanner .startPosition ;
1580- typeRefStartPosition = this .scanner .getCurrentTokenStartPosition ();
1581- typeRef = parseURLReference ();
1582- checkMarkdownLinkSyntaxValid (currStartPos );
1583- if (this .abort ) return false ;
1596+ if (this .source [this .scanner .getCurrentTokenStartPosition () - 1 ] == '(' ) {
1597+ if (isURLScheme (identifier )) {
1598+ if (isFollowedByURLPattern ()) {
1599+ if (typeRef == null ) {
1600+ int currStartPos = this .scanner .startPosition ;
1601+ typeRefStartPosition = this .scanner .getCurrentTokenStartPosition ();
1602+ typeRef = parseURLReference (true );
1603+ checkMarkdownLinkSyntaxValid (currStartPos , true );
1604+ if (this .abort ) return false ;
1605+ }
15841606 }
1607+ } else if (this .source [this .scanner .getCurrentTokenEndPosition () +1 ] == '.' ) { //$NON-NLS-1$
1608+ int currStartPos = this .scanner .startPosition ;
1609+ typeRefStartPosition = this .scanner .getCurrentTokenStartPosition ();
1610+ typeRef = parseURLReference (false );
1611+ checkMarkdownLinkSyntaxValid (currStartPos , true );
1612+ if (this .abort ) return false ;
15851613 }
15861614 }
15871615 if (typeRef == null ) {
0 commit comments