Don't escape search text in search page title
ClosedPublic

Authored by ngraham on Jan 31 2020, 10:45 PM.

Details

Summary

Doing so makes the title display look ugly and generated a bug report. Instead of escaping
HTML entities, this patch just removes them.

BUG: 416781
FIXED-IN: 5.18.0

Test Plan

Searching still works

Search terms with HTML-unsafe characters in them no longer look ugly in the title:

Diff Detail

Repository
R134 Discover Software Store
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Jan 31 2020, 10:45 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJan 31 2020, 10:45 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
ngraham requested review of this revision.Jan 31 2020, 10:45 PM
apol added a comment.Feb 3 2020, 5:08 PM

Because if you enter my <u>potato</u> it gets styled, which shouldn't happen.

I suggest just doing the following:

diff --git a/discover/qml/ApplicationsListPage.qml b/discover/qml/ApplicationsListPage.qml
index 4445a195..e094b667 100644
--- a/discover/qml/ApplicationsListPage.qml
+++ b/discover/qml/ApplicationsListPage.qml
@@ -52,11 +52,8 @@ DiscoverPage {
 
     function escapeHtml(unsafe) {
         return unsafe
-            .replace(/&/g, "&amp;")
             .replace(/</g, "&lt;")
-            .replace(/>/g, "&gt;")
-            .replace(/"/g, "&quot;")
-            .replace(/'/g, "&#039;");
+            .replace(/>/g, "&gt;");
     }
 
     background: Rectangle {

Why would the user enter my <u>potato</u>?

apol added a comment.Feb 3 2020, 6:32 PM

They shouldn't that doesn't mean we should style it when they do.

ngraham updated this revision to Diff 74948.Feb 3 2020, 7:20 PM

Just strip all html tags

ngraham edited the summary of this revision. (Show Details)Feb 3 2020, 10:03 PM
ngraham edited the test plan for this revision. (Show Details)
apol added a comment.Feb 7 2020, 9:46 AM

So with this change, if you search "<b>potato</b>", you'll get as a title "potato". I wouldn't say that's entirely correct.

Why is that not entirely correct? The bold tags are just styling; the user clearly intended to search for the word "potato".

apol added a comment.Feb 7 2020, 1:34 PM

Why is that not entirely correct? The bold tags are just styling; the user clearly intended to search for the word "potato".

Because the user actually wrote "<b>potato</b>", it's only styling because you're thinking of html :)

But again, what user would actually write, by hand, "<b>potato</b>" in the search field? When users type into a search field, they don't add HTML styling. That only happens if they're copying and pasting from another source. In this case, if that do that and the tags come along for the ride, I'm claiming that the tags are unintentional and should be stripped to reflect the user's true intent--which is to search for the word "potato".

I feel like I'm missing something here.

apol accepted this revision.Feb 7 2020, 2:49 PM

whatever

This revision is now accepted and ready to land.Feb 7 2020, 2:49 PM
This revision was automatically updated to reflect the committed changes.