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 1BEE4200C25 for ; Fri, 24 Feb 2017 20:26:49 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1A839160B69; Fri, 24 Feb 2017 19:26:49 +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 64778160B62 for ; Fri, 24 Feb 2017 20:26:48 +0100 (CET) Received: (qmail 73870 invoked by uid 500); 24 Feb 2017 19:26:47 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 73860 invoked by uid 99); 24 Feb 2017 19:26:47 -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; Fri, 24 Feb 2017 19:26:47 +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 2C02A18E83B for ; Fri, 24 Feb 2017 19:26:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.547 X-Spam-Level: X-Spam-Status: No, score=-1.547 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-2.999, SPF_NEUTRAL=0.652] autolearn=disabled 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 ay9rpQMsQq9W for ; Fri, 24 Feb 2017 19:26:46 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 9C85C5FAFB for ; Fri, 24 Feb 2017 19:26:45 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C5EDFE08B8 for ; Fri, 24 Feb 2017 19:26:44 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2EABB24138 for ; Fri, 24 Feb 2017 19:26:44 +0000 (UTC) Date: Fri, 24 Feb 2017 19:26:44 +0000 (UTC) From: "Yasser Zamani (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (WW-4742) Problem with escape when the key from getText has no value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 24 Feb 2017 19:26:49 -0000 [ https://issues.apache.org/jira/browse/WW-4742?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1588336= 7#comment-15883367 ]=20 Yasser Zamani edited comment on WW-4742 at 2/24/17 7:26 PM: ------------------------------------------------------------ [~mtsbarbosa], your application should not reach those lines normally becau= se those lines will execute only if Struts cannot resolve your key (i.e. Ob= rigat=C3=B3rio) to a value. If you want just a constant string (i.e. "Obrig= at=C3=B3rio - not mapped word in any dictionary") there, then you do not ne= ed +<@s.text+ tag at all and if you need to resolve the "Obrigat=C3=B3rio" = to a string according to user selected locale, then create a file named _.properties beside your action which returns that f= tl and *save it as ISO-8859-1* e.g. {code:title=3DMyFtlAction.properties|borderStyle=3Dsolid} Obrigat=C3=B3rio=3DRequired {code} {code:title=3DMyFtlAction_de.properties|borderStyle=3Dsolid} Obrigat=C3=B3rio=3Dverplicht {code} then *save your message.ftl as UTF-8* as below {code:title=3Dmessage.ftl|borderStyle=3Dsolid} ... <@s.text name=3D"Obrigat=C3=B3rio" /> ... {code} Currently Struts just pass a Locale to freemarker rather than any encoding,= so freemarker uses it's default (UTF-8) to read your ftl files. I will be working on it if Struts can also provide the encoding for underly= ing freemarker, which will enable you to save ftl files as different encodi= ngs. [~lukaszlenart], is it needed to working on? however, freemarker has s= ome locale-encoding mapping which simply can be enabled in Struts. was (Author: yasser.zamani): [~mtsbarbosa], your application should not reach those lines normally becau= se those lines will execute only if Struts cannot resolve your key (i.e. Ob= rigat=C3=B3rio) to a value. If you want just a constant string (i.e. "Obrig= at=C3=B3rio - not mapped word in any dictionary") there, then you do not ne= ed +<@s.text+ tag at all and if you need to resolve the "Obrigat=C3=B3rio" = to a string according to user selected locale, then create a file named _.properties beside your action which returns that f= tl and *save it as ISO-8859-1* e.g. {code:title=3DMyFtlAction.properties|borderStyle=3Dsolid} Obrigat=C3=B3rio=3DRequired {code} {code:title=3DMyFtlAction_de.properties|borderStyle=3Dsolid} Obrigat=C3=B3rio=3Dverplicht {code} then *save your message.ftl as UTF-8* as below {code:title=3Dmessage.ftl|borderStyle=3Dsolid} ... <@s.text name=3D"Obrigat=C3=B3rio - not mapped word in any dictionary" /> ... {code} Currently Struts just pass a Locale to freemarker rather than any encoding,= so freemarker uses it's default (UTF-8) to read your ftl files. I will be working on it if Struts can also provide the encoding for underly= ing freemarker, which will enable you to save ftl files as different encodi= ngs. [~lukaszlenart], is it needed to working on? however, freemarker has s= ome locale-encoding mapping which simply can be enabled in Struts. > Problem with escape when the key from getText has no value > ---------------------------------------------------------- > > Key: WW-4742 > URL: https://issues.apache.org/jira/browse/WW-4742 > Project: Struts 2 > Issue Type: Bug > Components: Core Tags > Affects Versions: 2.5.8, 2.5.10 > Reporter: Mateus Carvalho > Priority: Minor > Fix For: 2.5.next > > > When using an encoding like ISO-8859-1 and having the following situation= : > {code:title=3Dmessage.ftl|borderStyle=3Dsolid} > ... > <@s.text name=3D"Obrigat=C3=B3rio - not mapped word in any dictionary" /> > ... > {code} > We have the following output after update 2.5.8: > {code} > Obrigat\u00F3rio - not mapped word in any dictionary > {code} > After careful look at the source code and issues from the 2.5.8 I found t= he problem happens just in one added line on WW-4712, the following part of= the code: > {code:title=3DTextProviderHelper.java|borderStyle=3Dsolid} > ... > public static String getText(String key, String defaultMessage, List args, ValueStack stack, boolean searchStack) { > ... > //This escape causes the problem > msg =3D StringEscapeUtils.escapeEcmaScript(msg); > ... > } > ... > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)