Bug 856019 - Java variables validation does not recognize variables after an odd number of apostrophes
Java variables validation does not recognize variables after an odd number of...
Status: CLOSED DUPLICATE of bug 872039
Product: Zanata
Classification: Community
Component: Component-UI (Show other bugs)
1.7
Unspecified Unspecified
unspecified Severity low
: ---
: 1.7
Assigned To: Carlos Munoz
Ding-Yi Chen
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-10 21:35 EDT by David Mason
Modified: 2014-07-02 20:40 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-09-11 01:22:52 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-09-10 21:35:59 EDT
Description of problem:
For any java variable that appears in a string after an odd number of apostrophe ("'") characters, the variable is not recognised for validation. This can cause confusing messages of added or missing variables when using words containing apostrophes. Variables that are after an even number of apostrophes are validated as normal.

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


How reproducible:
Always

Steps to Reproduce:
1.Sign in and enter a workspace that has java style variables ( %{name} )
2.Copy a source string with variables to the target
3.Add a single apostrophe at the beginning of the string
4.Add another apostrophe next to the first
  
Actual results:
3.Validation shows all variables are missing
4.Validation does not show missing variables

Expected results:
Validation does not show missing variables at step 3 or 4

Additional info:
Caused by validator considering string 'quoted' between apostrophes and intentionally not validating.
Comment 1 Carlos Munoz 2012-09-10 21:43:44 EDT
Removed quote analysis from the validation.

See:
https://github.com/zanata/zanata/commit/503002118d3f9634c7bdd73cdca8afe9c727e2a4
Comment 2 Carlos Munoz 2012-09-11 01:22:52 EDT
Reverting this change as Java validation was working as expected. The bug was reported while attempting to validate Ruby code using the Java validator. A ruby variable validator should be implemented instead.

See:
https://github.com/zanata/zanata/commit/6a5b10a64b70031d21bc3287cdffbcc27c364de9
Comment 3 Sean Flanigan 2012-09-11 01:32:26 EDT
(Mid-air collision...)

Actually, the validator was working as it should: apostrophes (single quotes) are used for escaping in Java MessageFormat: http://docs.oracle.com/javase/1.4.2/docs/api/java/text/MessageFormat.html

To get a single quote with MessageFormat, you actually have to use two in a row.  Anything inside a quoted area that looks like a variable expansion will be output verbatim by MessageFormat, ie not treated as a variable.

The string given in the steps to reproduce ("%{name}") appears to be a Ruby string, not a Java string.  Until we implement a Ruby validator in the editor, it's best just to disable the Java validator for Ruby projects.

We should revert the above commit, please.  The quote analysis is fine.
Comment 4 Ding-Yi Chen 2014-07-02 20:40:51 EDT

*** This bug has been marked as a duplicate of bug 872039 ***

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