Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 840F311E9C for ; Sun, 22 Jun 2014 20:50:25 +0000 (UTC) Received: (qmail 48561 invoked by uid 500); 22 Jun 2014 20:50:25 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 48472 invoked by uid 500); 22 Jun 2014 20:50:25 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 48434 invoked by uid 99); 22 Jun 2014 20:50:25 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Jun 2014 20:50:25 +0000 Date: Sun, 22 Jun 2014 20:50:25 +0000 (UTC) From: "Yegor Bugayenko (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (LANG-1019) StringEscapeUtils.escapeXPath() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-1019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14040242#comment-14040242 ] Yegor Bugayenko edited comment on LANG-1019 at 6/22/14 8:48 PM: ---------------------------------------------------------------- Here is how I would implement it: {noformat} public static String escapeXPath(final String text) { return new StringBuilder(Tv.FIFTY + text.length()) .append("concat('") .append(text.replace("\'", "', \"'\", '")) .append("')") .toString(); } {noformat} was (Author: yegor256): Here is how I would implement it: {noformat} public static String escapeXPath(final String text) { return new StringBuilder(Tv.FIFTY + text.length()) .append("concat('") .append(text.replace("\'", "', \"'\", '")) .append("\')") .toString(); } {noformat} > StringEscapeUtils.escapeXPath() > ------------------------------- > > Key: LANG-1019 > URL: https://issues.apache.org/jira/browse/LANG-1019 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* > Affects Versions: 3.3.2 > Reporter: Yegor Bugayenko > > Would be great to create a method that would escape a string for XPath. It is a well known problem that XPath doesn't have a mechanism for quotes escaping. See for example http://stackoverflow.com/questions/14822153/escape-single-quote-in-xpath-with-nokogiri > A very good workaround suggested here https://bugs.php.net/bug.php?id=51785 > Would be great to add a method to StringEscapeUtils -- This message was sent by Atlassian JIRA (v6.2#6252)