Closed Bug 358472 Opened 18 years ago Closed 18 years ago

Search field should not allow control characters

Categories

(Camino Graveyard :: Toolbars & Menus, defect)

PowerPC
macOS
defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED
Camino1.5

People

(Reporter: bdeb, Assigned: bdeb)

Details

(Keywords: fixed1.8.1.1)

Attachments

(1 file)

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
I agree, and the patch looks reasonable. r=me.
Assignee: nobody → bdeb
Status: UNCONFIRMED → NEW
Ever confirmed: true
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
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)
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 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+
Checked in on 1.8branch and trunk.
Status: NEW → RESOLVED
Closed: 18 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.

Attachment

General

Creator:
Created:
Updated:
Size: