docs: public static String escapeLink(String source) {
  
          if (source == null) {
              return null;
          }
          StringBuffer result = new StringBuffer(source.length() * 2);
          int terminatorIndex;
          for (int i = 0; i < source.length(); ++i) {
              char ch = source.charAt(i);
              switch (ch) {
                  case '&':
                      // don't escape already escaped &amps;
                      terminatorIndex = source.indexOf(';', i);
                      if (terminatorIndex > 0) {
                          String substr = source.substring(i + 1, terminatorIndex);
                          if ("amp".equals(substr)) {
                              result.append(ch);
                          } else {
                              result.append("&amp;");
                          }
                      } else {
                          result.append("&amp;");
                      }
                      break;
                  default:
                      result.append(ch);
              }
          }
          return new String(result);
      }