Uploaded image for project: 'Maven Shared Components'
  1. Maven Shared Components
  2. MSHARED-489

AbstractMavenReportRenderer#linkPatternedText ignores name if href is invalid

    XMLWordPrintableJSON

Details

    Description

      Consider this input:

      {My Text, ftp://host/file.txt} or {My Text, http:/host/file.txt} (typo)
      

      The current output simply be ftp://host/file.txt or http:/host/file.txt but I would expect it to be My Text in both cases.

      The problem is burried in the current code:

      for ( Iterator<String> it = segments.iterator(); it.hasNext(); )
      {
          String name = it.next();
          String href = it.next();
      
          if ( href == null )
          {
              text( name );
          }
          else
          {
              if ( getValidHref( href ) != null )
              {
                  link( getValidHref( href ), name );
              }
              else
              {
                  text( href );
              }
          }
      }
      

      The invalid href would be printed out instead of name. I think the code should read:

      for ( Iterator<String> it = segments.iterator(); it.hasNext(); )
      {
          String name = it.next();
          String href = it.next();
      
          if ( getValidHref( href ) == null )
          {
              text( name );
          }
          else
          {
              link( getValidHref( href ), name );
          }
      }
      

      Produce link if href isn't null and is valid otherwise add name (text) only.

      Attachments

        Issue Links

          Activity

            People

              michael-o Michael Osipov
              michael-o Michael Osipov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: