php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62944 Missing escape character
Submitted: 2012-08-27 08:19 UTC Modified: 2014-02-15 19:30 UTC
From: stefan dot neuhaus at rwth-aachen dot de Assigned: omars (profile)
Status: Closed Package: solr (PECL)
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stefan dot neuhaus at rwth-aachen dot de
New email:
PHP Version: OS:

 

 [2012-08-27 08:19 UTC] stefan dot neuhaus at rwth-aachen dot de
Description:
------------
---
From manual page: http://www.php.net/solrutils.escapequerychars
---
When escaping a String like 

+423asdAS/kasd/

with SolrUtils::escapeQueryChars ( string $str ) like this:

SolrUtils::escapeQueryChars ('+423asdAS/kasd/');

and then searching with it, solr returns:

"error":{
    "msg":"org.apache.lucene.queryparser.classic.ParseException: Cannot parse 
'somefield:\\+423asdAS/kasd/': Lexical error at line 1, column 63.  Encountered: 
<EOF> after : \"\"",
    "code":400}}

Workaround:

str_replace("/","\\/",SolrUtils::escapeQueryChars ('+423asdAS/kasd/'));


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-26 19:27 UTC] eric dot caron at gmail dot com
Could you provide a bug report with more specific examples (e.g. "Expected" vs "Actual" style)?

Based on Lucene's specs (http://lucene.apache.org/core/3_6_0/queryparsersyntax.html#Escaping%20Special%20Characters), forward-slash does not need to be escaped. Furthermore, the example you're mentioning reads like the error has to do with a double-quote in the string, rather than the slash.
 [2014-02-14 21:14 UTC] omars@php.net
as of solr 4.0, solr accepts regex, so the forward slash shall be added to the escape characters. It'll be fixed in the next release
 [2014-02-14 21:15 UTC] omars@php.net
-Assigned To: +Assigned To: omars
 [2014-02-15 19:11 UTC] omars@php.net
-Operating System: Linux Debian Squeeze +Operating System: All
 [2014-02-15 19:11 UTC] omars@php.net
-Type: Bug +Type: Feature/Change Request
 [2014-02-15 19:30 UTC] omars@php.net
-Status: Assigned +Status: Closed
 [2014-02-15 19:30 UTC] omars@php.net
Implemented on master branch
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 13:01:33 2025 UTC