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 1af4c34b9949ad1e8afa6e69f9a2c89cc819457a 1 parent 0411126
Sebastian Zartner authored
45  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,12 +625,11 @@ 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
632 632
 
633  
-
634 633
 //deprecated compatibility functions
635 634
 Str.deprecateEscapeHTML = createSimpleEscape("text", "normal");
636 635
 
@@ -674,7 +673,7 @@ Str.formatSize = function(bytes)
674 673
         result = (Math.round((bytes/(1024*1024))*a)/a).toLocaleString() + " MB";
675 674
 
676 675
     return negative ? "-" + result : result;
677  
-}
  676
+};
678 677
 
679 678
 Str.formatTime = function(elapsed)
680 679
 {
@@ -692,10 +691,32 @@ Str.formatTime = function(elapsed)
692 691
         var sec = (elapsed % 60000);
693 692
         return min + "m " + (Math.round((elapsed/1000)%60)) + "s";
694 693
     }
695  
-}
  694
+};
  695
+
  696
+/**
  697
+ * Formats an IPv4 or IPv6 address incl. port
  698
+ * @param {String} address IP address to format
  699
+ * @param {String} [port] IP port to format
  700
+ * @returns {String} Formatted IP address
  701
+ */
  702
+Str.formatIP = function(address, port)
  703
+{
  704
+    if (!address || address == "")
  705
+        return "";
  706
+
  707
+    var result = address;
  708
+    var isIPv6Address = address.indexOf(":") != -1;
  709
+    if (isIPv6Address)
  710
+        result = "["+result+"]";
696 711
 
697  
-//********************************************************************************************* //
698  
-//Conversions
  712
+    if (port && port != "")
  713
+        result += ":"+port;
  714
+
  715
+    return result;
  716
+};
  717
+
  718
+// ********************************************************************************************* //
  719
+// Conversions
699 720
 
700 721
 Str.convertToUnicode = function(text, charset)
701 722
 {
16  extension/content/firebug/net/netReps.js
@@ -684,24 +684,12 @@ Firebug.NetMonitor.NetRequestEntry = domplate(Firebug.Rep, new Firebug.Listener(
684 684
 
685 685
     getLocalAddress: function(file)
686 686
     {
687  
-        var address = file.localAddress ? file.localAddress : "";
688  
-        var port = file.localPort ? file.localPort : "";
689  
-
690  
-        var result = address;
691  
-        result += result ? ":" : "";
692  
-        result += port;
693  
-        return result;
  687
+        return Str.formatIP(file.localAddress, file.localPort);
694 688
     },
695 689
 
696 690
     getRemoteAddress: function(file)
697 691
     {
698  
-        var address = file.remoteAddress ? file.remoteAddress : "";
699  
-        var port = file.remotePort ? file.remotePort : "";
700  
-
701  
-        var result = address;
702  
-        result += result ? ":" : "";
703  
-        result += port;
704  
-        return result;
  692
+        return Str.formatIP(file.remoteAddress, file.remotePort);
705 693
     },
706 694
 
707 695
     getElapsedTime: function(file)

0 notes on commit 1af4c34

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