Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6103F200C21 for ; Mon, 20 Feb 2017 16:30:50 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5FA23160B73; Mon, 20 Feb 2017 15:30:50 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 81150160B62 for ; Mon, 20 Feb 2017 16:30:49 +0100 (CET) Received: (qmail 12528 invoked by uid 500); 20 Feb 2017 15:30:43 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 12516 invoked by uid 99); 20 Feb 2017 15:30:43 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Feb 2017 15:30:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id DFB381857AE for ; Mon, 20 Feb 2017 15:30:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id OYQxJHYi6QtR for ; Mon, 20 Feb 2017 15:30:41 +0000 (UTC) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id ED8285F56B for ; Mon, 20 Feb 2017 15:30:40 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id r141so55533420wmg.1 for ; Mon, 20 Feb 2017 07:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=heYh/7m6HSIbhqOiF+JxCiuSIT0T5wmI2m1lP7pruqs=; b=ClRPu5oZpbFgpcrQ/TIeD1fun1n9OFA/D+z+H3lSNRmwjb0bE9TMZWpdUejVeqcEZD PeiPsux1q8StTlHwsmx9c018xjAcfPM8NMHkkPG1PGtCeia5qGA09i105x34prZ10y6N WwA8e007jhytJQktKHQEmoEP9Ixx6H8mCsN7WiWT4Bw+gPT6GF8qa8MiieFj9neQ6dQz yRtiQB672DXr+JodUJvX6BiaFVyuQv2sF9aRlTXFYyC+MgUU1wPMcEkzw1zJq4LtAYZ/ K3MwJwzCdQhpnahkfync1YWVyAulEB5Kt1eHtDaiBWTR1UkYY2WM0pRKcl3wp8x91tJh OsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=heYh/7m6HSIbhqOiF+JxCiuSIT0T5wmI2m1lP7pruqs=; b=G9WD5UigjnTDrd5mnUa/DIi1Zzqo3V+eOgGuirve/GQcaE9+ojDWVXUh2kNPzcPuEb Kyp4t0Gen0RSXFYyCFds7APROD3jFNjr0G+NJJpJs/mI/4Wo0HOiRJ0qskNbE+O54jug T/g27Z6a4e3BmsdaVRpzB+b/+owqLOwIAuqoPUpcd+nR4R3SF0NV495B9i860v41ijYQ /UDas0/OmYmE15k/qoLV4dUdEcQrNcd6LvoIPGD/cxlBeb0VSmayhRlN/bU3xeE00bER ef+EZ/uAYDzIDHcQ7rlnd2cilXWIKr/sA5EcTawLyTfRpqFK7K1JdakTMKL2E/0peRY3 TbyQ== X-Gm-Message-State: AMke39k0m/FHk35L57ng1y302aAK8RdzRVC+6zKL3J/80TXCs4TsjnSDHnC2vFeVcjuuxRlPyuZzlX9v4mjLFQ== X-Received: by 10.28.109.27 with SMTP id i27mr10723387wmc.54.1487604633503; Mon, 20 Feb 2017 07:30:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.151.217 with HTTP; Mon, 20 Feb 2017 07:30:32 -0800 (PST) In-Reply-To: References: <16A694D5-B641-49D3-815B-19F8C635DB6F@gmail.com> From: sebb Date: Mon, 20 Feb 2017 15:30:32 +0000 Message-ID: Subject: Re: [text] On the value of idempotent string escape methods? To: Commons Developers List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable archived-at: Mon, 20 Feb 2017 15:30:50 -0000 On 20 February 2017 at 14:55, Rob Tompkins wrote: > >> On Feb 20, 2017, at 4:31 AM, sebb wrote: >> >> On 19 February 2017 at 14:29, Raymond DeCampo > wrote: >>> I am trying to see how having the proposed unescape() method leads to a= n a >>> useful escape method. >>> >>> E.g. clearly unescape("&") would evaluate to "&". So would >>> unescape("&amp;"). That means the proposed escape() method would a= lso >>> have the same output for "&" and "&amp;". >>> >>> I think a better approach for an idempotent escape would be to just >>> unescape the string once, and then run the traditional escape. >> >> That does not eliminate the problems, as you state below. >> >>> You will >>> still have issues if the user intended to escape the string "&" but= you >>> are never going to crack that without some kind of state saving. >> >> That is my exact point. >> >> Since it's not possible for the function to work reliably, we should >> not mislead users by pretending that there is a magic method that >> works. >> >>> Than given that the functionality is available via to consecutive calls= to >>> existing methods, I would probably be disinclined to include it in the >>> library. >> >> +1 > > I=E2=80=99m a (+1) for removal as well. > > Also, I didn=E2=80=99t mean for my example to sound like a proposal. I me= rely was trying to get to a potentially valuable stateless idempotent strin= g escape function. Its contrivance it quite clear. > > Any other comments out there? > > We could provide a stateful escaper (that figures out how many escapes a = string is in), or a method that returns the number of escapes in a string i= s. Again, I=E2=80=99m not all that sure on the value of such methods. I don't think it's possible to work out the number of times a string has been escaped. The most one can do is to determine if a string has not been escaped. That would be the case where a string has one or more unescaped characters in it. For example "This & that" has obviously not been escaped. However if a string has no un-escaped characters it it, that does not necessarily mean that it has already been escaped. For example: "This & that". This might have been escaped - or it might not. For example it could be the answer to: "How does one code 'This & that' in HTML?" The application has to keep track of the escape-state of the string. > Cheers, > -Rob > >> >>> >>> On Sat, Feb 18, 2017 at 12:04 PM, Rob Tompkins wro= te: >>> >>>> In preparation for the 1.0 release, I think we should address Sebb's >>>> concern in TEXT-40 about the attempt to create "idempotent" string esc= ape >>>> methods. By idempotent I mean someMethod("some string") =3D >>>> someMethod(someMethod(someMethod(...someMethod("some string")))), a >>>> single application of a method is equal to any number of the applicati= ons >>>> of the method on the same input. >>>> >>>> Below I lay out a mechanism by which it is possible to write such meth= ods, >>>> but I don=E2=80=99t know the value in writing such methods. I'm merely= expressing >>>> that idempotency is a possibility. >>>> >>>> For string "un-escaping", I believe that we can write a method that, >>>> indeed, is idempotent by simply running the un-escape method the finit= e >>>> number of un-escapings to get to the point at which the string remains >>>> unchanged between applications of the un-escaping method. (I believe t= hat I >>>> can write a proof that all un-escape methods have such a point, if tha= t is >>>> needed for the sake of discussion). >>>> >>>> If indeed we can create an idempotent un-escape method, then we can si= mply >>>> take that method run it, and then run the escaping method one time. If= we >>>> always completely unescape and then escape once then we do have an >>>> idempotent method. >>>> >>>> Such a method might not be all that valuable to the user though. >>>> Furthermore, this just explains one way to create such an idempotent >>>> method. Whether or not more or more valuable methods exists, would tak= e >>>> some more though. >>>> >>>> Anyone have any thoughts? My feeling is that it might be more effort t= han >>>> it's worth to ensure that any string is only "singly encoded.=E2=80=9D= Further, we >>>> probably should give a look at the =E2=80=9Cescape_once=E2=80=9D metho= ds in >>>> StringEsapeUtils. >>>> >>>> Cheers >>>> -Rob >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>>> For additional commands, e-mail: dev-help@commons.apache.org >>>> >>>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org