8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2018-01-22 11:28:32 -08:00
parent 8550a5c92d
commit c0cb471231
2 changed files with 10 additions and 4 deletions

View File

@ -1752,8 +1752,9 @@ public class HtmlDocletWriter {
result.addContent(sb);
Content docRootContent = new ContentBuilder();
boolean isHRef = inAnAtag() && node.getName().toString().equalsIgnoreCase("href");
for (DocTree dt : node.getValue()) {
if (utils.isText(dt) && inAnAtag()) {
if (utils.isText(dt) && isHRef) {
String text = ((TextTree) dt).getBody();
if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) {
result.addContent(configuration.docrootparent);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 4460354 8014636 8043186
* @bug 4460354 8014636 8043186 8195805
* @summary Test to make sure that relative paths are redirected in the
* output so that they are not broken.
* @author jamieh
@ -67,7 +67,12 @@ public class TestRelativeLinks extends JavadocTester {
"<a href=\"./pkg/relative-field-link.html\">relative field link</a>",
"<a href=\"./pkg/relative-method-link.html\">relative method link</a>",
"<a href=\"./pkg/relative-package-link.html\">relative package link</a>",
" <a href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.",
" <a href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.");
// This is not a relative path and should not be redirected.
checkOutput("index-all.html", true,
"<div class=\"block\"><a name=\"masters\"></a>");
checkOutput("index-all.html", false,
"<div class=\"block\"><a name=\"./pkg/masters\"></a>");
// PACKAGE USE