Menu

Creating links to other bugs in comments

Help
2004-07-26
2013-04-16
  • Nobody/Anonymous

    In version 0.9.1, when you put "#1" in the comments for example, it creates a link to bug #1.
    Version 1.04rc4 tries to do the same thing, but all that happens is that you see
    <a href=/phpbt/bug.php?op=show&bugid=1>#1</a>
    instead of the actual link.
    Any clues as to why this is happening?

     
    • Nobody/Anonymous

      after playing around with it some more, i discovered that it does not display html tags at all.
      For some reason, it changes "<" to "&lt;" and ">" to "&gt;"
      Any way to fix this?

       
      • Eric

        Eric - 2006-07-25

        This is still a problem for me in phpbt 1.0.1 but the bugdisplay.html no longer has this code in it. When I try to add a hyperlink in the comments of a bug I see the actual code and not a hyperlink. In bug.php I found the following code
        <a href="'.CVS_WEB.'\\1#rev\\4" target="_new">
        which seems to be the problem because I see this in the comment of the bug. Anyone else having this problem?

         
    • Nobody/Anonymous

      Found the solution...
      in bugdisplay.html around line 234, where it says

      <td><?php echo stripslashes(htmlspecialchars(format_comments(nl2br($comments[$i]['comment_text'])))); ?><br><br></td>

      put

      <td><?php echo stripslashes(format_comments(nl2br($comments[$i]['comment_text']))); ?> <br><br></td>

         

       
    • Jon Haynes

      Jon Haynes - 2007-05-01

      I changed function format_comments() in /bug.php to sort this out as follows:

      /// Beautify the bug comments
      function format_comments($comments) {
              global $me;

              // Set up the regex replacements

              // This didn't work as it was hyperlinking bug numbers and then making < and > into &lt; and &gt;
              // so I've split the regexp into 2 stages.
              $patterns1 = array(
                      '/</',
                      '/>/'
                      );

              $replacements1 = array(
                      '&lt;',
                      '&gt;'
                      );

              $patterns2 = array(
                      '/(bug)[[:space:]]*(#?)([0-9]+)/i', // matches bug #nn
                      '/cvs:([^\.\s:,\?!]+(\.[^\.\s:,\?!]+)*)(:)?(\d\.[\d\.]+)?([\W\s])?/i' // matches cvs:filename.php or cvs:filename.php:n.nn
                      );
              $replacements2 = array(
                      "\\1 <a href='$me?op=show&bugid=\\3'>\\2\\3</a>", // internal link to bug
                      '<a href="'.CVS_WEB.'\\1#rev\\4" target="_new">\\1</a>\\5' // external link to cvs web interface
                      );

              $replace1 = preg_replace($patterns1, $replacements1, stripslashes($comments));
              return nl2br(preg_replace($patterns2, $replacements2, $replace1));
      }

       
    • Eric

      Eric - 2008-01-17

      Hey Jon, thanks for the code sample. I put this into my bug.php and found that it fixed the hyper link issue that I was seeing. Thanks again.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.