Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/java/net/URI.java
          +++ new/src/share/classes/java/net/URI.java
↓ open down ↓ 1821 lines elided ↑ open up ↑
1822 1822              if (needBrackets) sb.append('[');
1823 1823              sb.append(host);
1824 1824              if (needBrackets) sb.append(']');
1825 1825              if (port != -1) {
1826 1826                  sb.append(':');
1827 1827                  sb.append(port);
1828 1828              }
1829 1829          } else if (authority != null) {
1830 1830              sb.append("//");
1831 1831              if (authority.startsWith("[")) {
     1832 +                // authority should (but may not) contain an embedded IPv6 address
1832 1833                  int end = authority.indexOf("]");
1833      -                if (end != -1 && authority.indexOf(":")!=-1) {
1834      -                    String doquote, dontquote;
     1834 +                String doquote = authority, dontquote = "";
     1835 +                if (end != -1 && authority.indexOf(":") != -1) {
     1836 +                    // the authority contains an IPv6 address
1835 1837                      if (end == authority.length()) {
1836 1838                          dontquote = authority;
1837 1839                          doquote = "";
1838 1840                      } else {
1839      -                        dontquote = authority.substring(0,end+1);
1840      -                        doquote = authority.substring(end+1);
     1841 +                        dontquote = authority.substring(0 , end + 1);
     1842 +                        doquote = authority.substring(end + 1);
1841 1843                      }
1842      -                    sb.append (dontquote);
1843      -                    sb.append(quote(doquote,
     1844 +                }
     1845 +                sb.append(dontquote);
     1846 +                sb.append(quote(doquote,
1844 1847                              L_REG_NAME | L_SERVER,
1845 1848                              H_REG_NAME | H_SERVER));
1846      -                }
1847 1849              } else {
1848 1850                  sb.append(quote(authority,
1849 1851                              L_REG_NAME | L_SERVER,
1850 1852                              H_REG_NAME | H_SERVER));
1851 1853              }
1852 1854          }
1853 1855      }
1854 1856  
1855 1857      private void appendSchemeSpecificPart(StringBuffer sb,
1856 1858                                            String opaquePart,
↓ open down ↓ 1666 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX