Bug 826877 - Preview fails when replace term has single \ or $
Preview fails when replace term has single \ or $
Status: CLOSED CURRENTRELEASE
Product: Zanata
Classification: Community
Component: Component-UI (Show other bugs)
1.6-SNAPSHOT
Unspecified Unspecified
high Severity high
: ---
: 1.6.1
Assigned To: David Mason
Ding-Yi Chen
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-31 03:56 EDT by David Mason
Modified: 2012-07-03 01:27 EDT (History)
2 users (show)

See Also:
Fixed In Version: 1.6.1-SNAPSHOT (20120606-0019)
Doc Type: Bug Fix
Doc Text:
This is a known issue in 1.6, and is fixed in 1.6.1. Cause Replacement phrase on search-and-replace page is not properly escaped. Consequence Preview fails or does not behave as expected in some cases when it contains a '$' or '\': - a single '\' not followed by another character causes failure - a single '\' followed by another character will be dropped from the replacement - a '$' not preceded by a '\' causes failure Workaround (1.6) Enter "\\" instead of "\" and "\$" instead of "$" in the replacement text box. Fix (1.6.1) Replacement phrase is now escaped properly in the code. Result '\' and '$' now behave as expected with no special treatment required.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-07-03 01:27:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Mason 2012-05-31 03:56:09 EDT
Description of problem:
Preview fails if a single '\' not followed by another character, or a '$' with no '\' in front of it is entered in the replacement box.

Version-Release number of selected component (if applicable):
1.6

How reproducible:
Always

Steps to Reproduce:
1.Sign in, navigate to search-and-replace page
2.Search for any string that returns results
3.Select at least one row in results
4.Enter '\' in replacement box and press Enter
5.Enter '$' in replacement box and press Enter
6.Enter '\a' in replacement box and press Enter
  
Actual results:
4. notification says 'failed to fetch preview'
5. notification says 'failed to fetch preview'
6. preview shows with only 'a' in the replacement

Expected results:
4 and 5: successfully show previews with the entered character
6. preview shows with '\a' in the place of the search string

Additional info:
Using the same quoting for the replace term as for the search term in ReplaceTextHandler.java:89 should fix this.
Comment 1 David Mason 2012-05-31 03:57:01 EDT
Workaround: enter "\\" instead of "\" and "\$" instead of "$" in the preview text box.
Comment 2 David Mason 2012-05-31 21:32:24 EDT
Fixed in 1.6.1-SNAPSHOT

Above workaround will be required until the next release.

See https://github.com/zanata/zanata/commit/0beb2057d2f78263f1ace937ab70805e4c348590
Comment 3 David Mason 2012-06-06 21:25:55 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
This is a known issue in 1.6, and is fixed in 1.6.1.

Cause
Replacement phrase on search-and-replace page is not properly escaped.

Consequence
Preview fails  or does not behave as expected in some cases when it contains a '$' or '\':
 - a single '\' not followed by another character causes failure
 - a single '\' followed by another character will be dropped from the replacement
 - a '$' not preceded by a '\' causes failure

Workaround (1.6)
Enter "\\" instead of "\" and "\$" instead of "$" in the replacement text box.

Fix (1.6.1)
Replacement phrase is now escaped properly in the code.

Result
'\' and '$' now behave as expected with no special treatment required.
Comment 4 Ding-Yi Chen 2012-06-06 21:37:28 EDT
VERIFIED with Zanata version 1.6.1-SNAPSHOT (20120606-0019)

Note You need to log in before you can comment on or make changes to this bug.