Commit 0686a9f
committed
GROOVY-12277: Encode source-derived text emitted into generated HTML
Two places where groovydoc builds HTML around text taken from the source it
is documenting, without encoding it for the context it lands in.
A {@link} or @see reference is split into a target and a label, both of
which are then concatenated into an anchor the tool constructs: the target
into href, the label into the element text, and for a resolved class the
short name into title as well. None was encoded, so a reference could close
the attribute and open a tag of its own. Encode each for its context, the
attributes through encodeAttribute and the text through encodeAngleBrackets.
An annotation's name and description are emitted into the class declaration
and every member heading. description() carries the annotation's arguments
as they were written, so an annotation holding a string literal put that
literal into the page verbatim. Encode both, leaving the linkable() call
alone since that one does produce markup.
This is groovydoc's own construction rather than the raw HTML a doc comment
body may contain by javadoc parity, so the passthrough that covers a comment
body does not extend to it. For the annotation case the text is not from a
comment at all: it is source code, and reaches the page without any doc
comment being written.
Not changed: the @default tag GroovydocJavaVisitor appends for an annotation
member's default value. It is added to the raw comment text and no template
renders it as a declaration, and constantValueExpression() is only tested
for nullity, so that value does not reach a declaration block.1 parent 34ed575 commit 0686a9f
3 files changed
Lines changed: 85 additions & 3 deletions
File tree
- subprojects/groovy-groovydoc/src
- main
- java/org/codehaus/groovy/tools/groovydoc
- resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel
- test/groovy/org/codehaus/groovy/tools/groovydoc
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
661 | | - | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
662 | 665 | | |
663 | 666 | | |
664 | 667 | | |
| |||
738 | 741 | | |
739 | 742 | | |
740 | 743 | | |
741 | | - | |
| 744 | + | |
| 745 | + | |
742 | 746 | | |
743 | 747 | | |
744 | 748 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
388 | 463 | | |
389 | 464 | | |
390 | 465 | | |
| |||
0 commit comments