Fix highlighting of matches in text of escaped html entities
When highlighting matches in suggestions, the highlighting also matched text of escaped html entities. So for example typing "owner:L" in the search box showed a mangled "<" in front of the email address: "Lucy <mail@example.org>" (with all "L", and "l" in bold) instead of the plain "Lucy <mail@example.org>" (with all "L", and "l" in bold) We now un-mangle such matches in text of escaped html entities. Bug: issue 1574 Change-Id: Ifc0b4f4d52a2b2a5a6a511b943a11d752c186c39
This commit is contained in:
parent
9d2ca21962
commit
b4438e8606
@ -79,7 +79,18 @@ public abstract class HighlightSuggestOracle extends SuggestOracle {
|
||||
if (!html) {
|
||||
ds = escape(ds);
|
||||
}
|
||||
displayString = sgi(ds, qstr, "<strong>$1</strong>");
|
||||
|
||||
// We now surround qstr by <strong>. But the chosen approach is not too
|
||||
// smooth, if qstr is small (e.g.: "t") and this small qstr may occur in
|
||||
// escapes (e.g.: "Tim <email@example.org>"). Those escapes will
|
||||
// get <strong>-ed as well (e.g.: "<" -> "&<strong>l</strong>t;"). But
|
||||
// as repairing those mangled escapes is easier than not mangling them in
|
||||
// the first place, we repair them afterwards.
|
||||
ds = sgi(ds, qstr, "<strong>$1</strong>");
|
||||
// Repairing <strong>-ed escapes.
|
||||
ds = sgi(ds, "(&[a-z]*)<strong>([a-z]*)</strong>([a-z]*;)", "$1$2$3");
|
||||
|
||||
displayString = ds;
|
||||
}
|
||||
|
||||
private static native String sgi(String inString, String pat, String newHtml)
|
||||
|
Loading…
x
Reference in New Issue
Block a user