Issue (View Online)

Key: NXP-571
Issue Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Georges Racinet
Reporter: Olivier Grisel

Operations

View all
View comments
View history
Change the query(String query) method signature to handle escaping natively 
Updated: 02/05/07 17:03   Created: 07/02/07 19:45  

The following comment has been added to this issue: [ Permlink ]

Author: Georges Racinet
Date: 02/05/07 17:03
Comment:
Design draft with OG:
  - two public static methods on SQLQueryParser:
           + public String escapeStringLiteral(String s): escape a single literal
           + public String formatQuery(String format, Object... params): replaces occurences of '?' in the format by escaped serialization of parameters
           + public parse(String format, Object... params): relies on the previous one and the existing sig.
  - Stateful QueryModel builds its query incrementally. Therefore it'll use escapeStringLiteral
  - Stateless QueryModel will use the new parse sig to fire its requests and/or formatQuery to provide query string

Project: Nuxeo Enterprise Platform 5
Components: Query / Search
Affects Versions: 5.1 M2
Fix Versions: 5.1 M3

 Description   
Currently client components find documents by forging a string query such as:

   String myQuery = "SELECT * FROM document WHERE prefix1:field1 = 'value1' AND prefix2:field2 = 'value2'"

and then feeding it to:

   documentManager.query(myQuery)

Which is bad since it's up to the client code to implement NXQL escaping (security protection against NXQL injection).

So the new API instead accept:

  String myQuery = "SELECT * FROM document WHERE prefix1:field1 = ? AND prefix2:field2 = ?"
  Object[] params = new {"value1", "value2"};
  documentManager.query(myQuery, params);

and the NXQL escaping should be handled by the server as this is done with the PreparedStatement class of JDBC for instance.

This message was automatically generated by Atlassian JIRA Enterprise Edition, Version: 3.7.2-186 - Bug/feature request.
If you think it was sent incorrectly, contact one of this server's administrators.

_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets

Reply via email to