Bug 826877

Summary: Preview fails when replace term has single \ or $
Product: [Retired] Zanata Reporter: David Mason <damason>
Component: Component-UIAssignee: David Mason <damason>
Status: CLOSED CURRENTRELEASE QA Contact: Ding-Yi Chen <dchen>
Severity: high Docs Contact:
Priority: high    
Version: 1.6-SNAPSHOTCC: aeng, zanata-bugs
Target Milestone: ---   
Target Release: 1.6.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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 05:27:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Mason 2012-05-31 07:56:09 UTC
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 07:57:01 UTC
Workaround: enter "\\" instead of "\" and "\$" instead of "$" in the preview text box.

Comment 2 David Mason 2012-06-01 01:32:24 UTC
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-07 01:25:55 UTC
    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-07 01:37:28 UTC
VERIFIED with Zanata version 1.6.1-SNAPSHOT (20120606-0019)