Skip to content

Commit c92db39

Browse files
committed
ClipData: html attribute values should always be escaped
Failure to properly escape HTML attribute values can lead to XSS attacks. Technically, HTML of the form <a href="http://www.google.com/search?x=a&y=b">blah</a> is malformed (but widely accepted). Such links should be written as <a href="http://www.google.com/search?x=a&amp;y=b">blah</a> See: http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2 Change-Id: I188ded00b4cac44acb38884d4728c4cf9500f3b6
1 parent 527d14d commit c92db39

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/java/android/content/ClipData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ private CharSequence coerceToHtmlOrStyledText(Context context, boolean styled) {
563563
private String uriToHtml(String uri) {
564564
StringBuilder builder = new StringBuilder(256);
565565
builder.append("<a href=\"");
566-
builder.append(uri);
566+
builder.append(Html.escapeHtml(uri));
567567
builder.append("\">");
568568
builder.append(Html.escapeHtml(uri));
569569
builder.append("</a>");

0 commit comments

Comments
 (0)