Closed Bug 328134 Opened 19 years ago Closed 19 years ago

margin fields in page setup accept '^' and '|' characters

Categories

(Core :: Printing: Output, defect)

1.8 Branch
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla1.8.1

People

(Reporter: rcampbel, Assigned: Gavin)

Details

(Keywords: fixed-seamonkey1.1a, fixed1.8.1)

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060123 Firefox/1.5.0.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060123 Firefox/1.5.0.1 The margins allow users to enter the '^' character, which it always defaults back to '0' for the margin size. Reproducible: Always Steps to Reproduce: **Margin Box is what I am calling the "dotted" lines showing the pages margins.** 1. Go to File->Page Setup... 2. Go to the Margins & Header/Footer Tab 3. Enter '^' in any of the margin boxes 4. Notice Margin Box is redrawn 5. Close Page Setup window by selecting the OK button, or pressing your "enter" key 6. File->Page Setup... 7. Go to the Margins & Header/Footer tab 8. Notice value of margin that had '^' entered and size of Margin Box Actual Results: Margin with '^' entered defaults to '0' and the Margin Box is drawn with a zero value for that/those margins. *Can enter combination of numbers and '^'s, result is still the same.* Expected Results: I would expect the '^' character to be blocked by an input validator, or the character hold a mathematical function. *I experimented with several variations to try and find a mathematical function or relevance for the '^' character.*
Confirmed with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060214 Firefox/1.6a1. The source for this appears to be http://lxr.mozilla.org/seamonkey/source/xpfe/global/resources/content/printPageSetup.js#113 This function checks that the new margin value is really a double, and removes invalid characters using value.replace(/[^\.|^0-9]/g,""). I think that needs to be value.replace(/[^\.|0-9]/g,"") but I don't know enough JS to say without testing it. This code also appears in the toolkit directory: http://lxr.mozilla.org/seamonkey/source/toolkit/components/printing/content/printPageSetup.js#113
Assignee: nobody → printing
Severity: normal → minor
Status: UNCONFIRMED → NEW
Component: Page Info → Printing
Ever confirmed: true
Product: Firefox → Core
QA Contact: page.info
Version: unspecified → Trunk
Summary: Margin accepts invalid character '^'. → Margin accepts '^' and 'character.
Summary: Margin accepts '^' and 'character. → margin fields in page setup accept '^' and '|' characters
Assignee: printing → gavin.sharp
OS: Windows XP → All
Hardware: PC → All
Version: Trunk → 1.8 Branch
Attached patch fix bogus regexp usage (obsolete) — Splinter Review
This dates back to when the file was initially added in 2002.
Attachment #212780 - Flags: review?(neil)
Attachment #212780 - Flags: approval-branch-1.8.1?(neil)
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8.1
QA Contact: printing
Comment on attachment 212780 [details] [diff] [review] fix bogus regexp usage > function checkDouble(element) > { > var value = element.value; > if (value && value.length > 0) { >- value = value.replace(/[^\.|^0-9]/g,""); >+ value = value.replace(/[^\.0-9]/g,""); > if (!value) value = ""; > element.value = value; > } > } Nits: \ is also unnecessary because . isn't special inside []; space after , Bonus points for extra cleanup: > if (!value) value = ""; value can't be null here (code may originally have used match?) > if (value && value.length > 0) { if (value) fails unless value.length > 0 Then when you consider that the code has no harmful effects when value == "" you can reduce this function to one line :-)
Attachment #212780 - Flags: review?(neil)
Attachment #212780 - Flags: review+
Attachment #212780 - Flags: approval-branch-1.8.1?(neil)
Attachment #212780 - Flags: approval-branch-1.8.1+
Attached patch for checkinSplinter Review
Attachment #212780 - Attachment is obsolete: true
mozilla/xpfe/global/resources/content/printPageSetup.js 1.14.28.1 mozilla/toolkit/components/printing/content/printPageSetup.js 1.3.8.1 mozilla/toolkit/components/printing/content/printPageSetup.js 1.5 mozilla/xpfe/global/resources/content/printPageSetup.js 1.16
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: