QChris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/66387


Change subject: Fix highlighting of matches in text of escaped html entities
......................................................................

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 &lt;[email protected]>" (with all "L", and "l" in bold)
instead of the plain
  "Lucy <[email protected]>" (with all "L", and "l" in bold)
We now un-mangle such matches in text of escaped html entities.

Bug: bug 48979
Change-Id: Ifc0b4f4d52a2b2a5a6a511b943a11d752c186c39
---
M 
gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/HighlightSuggestOracle.java
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/gerrit refs/changes/87/66387/1

diff --git 
a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/HighlightSuggestOracle.java
 
b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/HighlightSuggestOracle.java
index e2c576b..61bec18 100644
--- 
a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/HighlightSuggestOracle.java
+++ 
b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/HighlightSuggestOracle.java
@@ -79,7 +79,18 @@
       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 &lt;[email protected]&gt;"). Those escapes will
+      // get <strong>-ed as well (e.g.: "&lt;" -> "&<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)

-- 
To view, visit https://gerrit.wikimedia.org/r/66387
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc0b4f4d52a2b2a5a6a511b943a11d752c186c39
Gerrit-PatchSet: 1
Gerrit-Project: gerrit
Gerrit-Branch: wmf
Gerrit-Owner: QChris <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to