Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Issue 5783 (Display of IPv6 addresses with port number is incorrect)

  • Loading branch information...
commit 4aed1a1d94937505155f975feea8f74658b36022 1 parent c0ffab9
Sebastian Zartner authored
40  extension/content/firebug/lib/string.js
@@ -386,7 +386,7 @@ Str.unescapeForTextNode = function(str)
386 386
         str = escapeForElementAttribute(str);
387 387
 
388 388
     return str;
389  
-}
  389
+};
390 390
 
391 391
 Str.unescapeForURL = createSimpleEscape('text', 'reverse');
392 392
 
@@ -532,17 +532,17 @@ Str.splitLines = function(text)
532 532
 Str.trim = function(text)
533 533
 {
534 534
     return text.replace(/^\s*|\s*$/g, "");
535  
-}
  535
+};
536 536
 
537 537
 Str.trimLeft = function(text)
538 538
 {
539 539
     return text.replace(/^\s+/, "");
540  
-}
  540
+};
541 541
 
542 542
 Str.trimRight = function(text)
543 543
 {
544 544
     return text.replace(/\s+$/, "");
545  
-}
  545
+};
546 546
 
547 547
 Str.hasPrefix = function(hay, needle)
548 548
 {
@@ -591,13 +591,13 @@ Str.wrapText = function(text, noEscapeHTML)
591 591
     }
592 592
 
593 593
     return html;
594  
-}
  594
+};
595 595
 
596 596
 Str.insertWrappedText = function(text, textBox, noEscapeHTML)
597 597
 {
598 598
     var html = Str.wrapText(text, noEscapeHTML);
599 599
     textBox.innerHTML = "<pre role=\"list\">" + html.join("") + "</pre>";
600  
-}
  600
+};
601 601
 
602 602
 // ************************************************************************************************
603 603
 // Indent
@@ -625,7 +625,7 @@ Str.cleanIndentation = function(text)
625 625
             lines[i] = line.substr(minIndent);
626 626
     }
627 627
     return lines.join("");
628  
-}
  628
+};
629 629
 
630 630
 // ************************************************************************************************
631 631
 // Formatting
@@ -679,7 +679,7 @@ Str.formatSize = function(bytes)
679 679
         result = Math.round((bytes/(1024*1024))*a)/a + " MB";
680 680
 
681 681
     return negative ? "-" + result : result;
682  
-}
  682
+};
683 683
 
684 684
 Str.formatTime = function(elapsed)
685 685
 {
@@ -697,7 +697,29 @@ Str.formatTime = function(elapsed)
697 697
         var sec = (elapsed % 60000);
698 698
         return min + "m " + (Math.round((elapsed/1000)%60)) + "s";
699 699
     }
700  
-}
  700
+};
  701
+
  702
+/**
  703
+ * Formats an IPv4 or IPv6 address incl. port
  704
+ * @param {String} address IP address to format
  705
+ * @param {String} [port] IP port to format
  706
+ * @returns {String} Formatted IP address
  707
+ */
  708
+Str.formatIP = function(address, port)
  709
+{
  710
+    if (!address || address == "")
  711
+        return "";
  712
+
  713
+    var result = address;
  714
+    var isIPv6Address = address.indexOf(":") != -1;
  715
+    if (isIPv6Address)
  716
+        result = "["+result+"]";
  717
+
  718
+    if (port && port != "")
  719
+        result += ":"+port;
  720
+
  721
+    return result;
  722
+};
701 723
 
702 724
 //********************************************************************************************* //
703 725
 //Conversions
16  extension/content/firebug/net/netReps.js
@@ -681,24 +681,12 @@ Firebug.NetMonitor.NetRequestEntry = domplate(Firebug.Rep, new Firebug.Listener(
681 681
 
682 682
     getLocalAddress: function(file)
683 683
     {
684  
-        var address = file.localAddress ? file.localAddress : "";
685  
-        var port = file.localPort ? file.localPort : "";
686  
-
687  
-        var result = address;
688  
-        result += result ? ":" : "";
689  
-        result += port;
690  
-        return result;
  684
+        return Str.formatIP(file.localAddress, file.localPort);
691 685
     },
692 686
 
693 687
     getRemoteAddress: function(file)
694 688
     {
695  
-        var address = file.remoteAddress ? file.remoteAddress : "";
696  
-        var port = file.remotePort ? file.remotePort : "";
697  
-
698  
-        var result = address;
699  
-        result += result ? ":" : "";
700  
-        result += port;
701  
-        return result;
  689
+        return Str.formatIP(file.remoteAddress, file.remotePort);
702 690
     },
703 691
 
704 692
     getElapsedTime: function(file)

0 notes on commit 4aed1a1

Please sign in to comment.
Something went wrong with that request. Please try again.