Search field should not allow control characters

RESOLVED FIXED in Camino1.5

Status

Camino Graveyard
Toolbars & Menus
--
minor
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: Ben Willmore, Assigned: Ben Willmore)

Tracking

({fixed1.8.1.1})

unspecified
Camino1.5
PowerPC
Mac OS X
fixed1.8.1.1

Details

Attachments

(1 attachment)

(Assignee)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.9a1) Gecko/20061027 Camino/1.2+
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.9a1) Gecko/20061027 Camino/1.2+

The Google search field does not deal well with control characters.  For example, select several lines of text from a web page.  Cmd-C, Cmd-V copy-paste them into the google search field.  The text is displaced downwards a few pixels, the highlight looks odd, and it is non-obvious that there are multiple lines of text in the field.

Pressing option-enter when typing into the field is similarly confusing.

I cannot currently think of a reason why control characters would be allowed in this field. Hence:

Index: browser/SearchTextField.m
===================================================================
RCS file: /cvsroot/mozilla/camino/src/browser/SearchTextField.m,v
retrieving revision 1.16
diff -u -d -b -w -u -8 -r1.16 SearchTextField.m
--- browser/SearchTextField.m   23 Mar 2006 23:08:23 -0000      1.16
+++ browser/SearchTextField.m   28 Oct 2006 05:50:11 -0000
@@ -144,16 +144,17 @@
 
 - (void)setHasPopUpButton:(BOOL)aBoolean
 {
   [[self cell] setHasPopUpButton:aBoolean];
 }
 
 - (void)textDidChange:(NSNotification *)aNotification
 {
+  [self setStringValue:[[self stringValue] stringByRemovingCharactersInSet:[NSCharacterSet controlCharacterSet]]];
   [[self cell] searchSubmittedFromView:self];
   [super textDidChange: aNotification];
 }
 
 //
 // -setStringValue:
 //
 // Override to display the clear (x) when setting the search bar's text


Reproducible: Always
(Assignee)

Comment 1

11 years ago
Created attachment 243878 [details] [diff] [review]
patch without erroneous line breaks

Comment 2

11 years ago
I agree, and the patch looks reasonable. r=me.
Assignee: nobody → bdeb
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 3

11 years ago
Fixing summary/OS, targeting for 1.1.
OS: Mac OS X 10.4 → Mac OS X 10.3
Summary: Google search field behaves confusingly if control characters are entered → Search field should not allow control characters
Target Milestone: --- → Camino1.1

Updated

11 years ago
Attachment #243878 - Flags: superreview?(mikepinkerton)
Attachment #243878 - Flags: review+
Comment on attachment 243878 [details] [diff] [review]
patch without erroneous line breaks

I think Stuart can probably sr this one ;)
Attachment #243878 - Flags: superreview?(mikepinkerton) → superreview?(stuart.morgan)

Comment 5

11 years ago
Is there any reason to do this instead of using a formatter on the field to prevent control character input?  That would have the advantage of not going away and needing to be reimplemented when we rip out the fake search fields.

Comment 6

11 years ago
Comment on attachment 243878 [details] [diff] [review]
patch without erroneous line breaks

I guess since it's done there's no real reason not to check it in, so sr=me.  I just hate to see fixes going into a class that we are already planning to remove.
Attachment #243878 - Flags: superreview?(stuart.morgan) → superreview+

Comment 7

11 years ago
Checked in on 1.8branch and trunk.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Keywords: fixed1.8.1.1
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.