Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
[hidden email] wrote:

> Author: jleroux
> Date: Wed Mar 10 16:12:30 2010
> New Revision: 921421
>
> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
> Log:
> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>
> Modified:
>     ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>
> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
> @@ -97,7 +97,7 @@
>      </property>
>      <property key="ExampleDateField10Tooltip">
>          <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>          <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>          <value xml:lang="zh">同上,使用nowTimstamp变量(在表单中总是可用的)来把缺省值设置为现在</value>
>      </property>

tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
characters, like < or > or &.

Additionally, appendTooltip should not be using a StringWriter.


>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Scott Gray-2
On 10/03/2010, at 9:48 AM, Adam Heath wrote:

> [hidden email] wrote:
>> Author: jleroux
>> Date: Wed Mar 10 16:12:30 2010
>> New Revision: 921421
>>
>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>> Log:
>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>
>> Modified:
>>    ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>
>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>> @@ -97,7 +97,7 @@
>>     </property>
>>     <property key="ExampleDateField10Tooltip">
>>         <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>         <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>         <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>     </property>
>
> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
> characters, like < or > or &.
It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
tooltip = encode(tooltip, modelFormField, context);

Regards
Scott

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
Scott Gray wrote:

> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>
>> [hidden email] wrote:
>>> Author: jleroux
>>> Date: Wed Mar 10 16:12:30 2010
>>> New Revision: 921421
>>>
>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>> Log:
>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>
>>> Modified:
>>>    ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>
>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>> @@ -97,7 +97,7 @@
>>>     </property>
>>>     <property key="ExampleDateField10Tooltip">
>>>         <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>         <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>         <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>     </property>
>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>> characters, like < or > or &.
>
> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
> tooltip = encode(tooltip, modelFormField, context);

That's what I mean, I went and looked at the method he referenced, to
know what the variable name was.

I also looked at the macro files themselves, and they will work if
passed this encoded string value.

However, from a perfectionist standpoint, it doesn't sit well with me.
 What happens if these macros use a string from a map, that is already
encoded, then try to double-encode it?

Ideally, MacroFormRenderer is calling freemarker.  So it should use
freemarker encodings of special characters.  Freemarker should then
decode said special markup, so that the macros it ends up calling can
do what they need for it.


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Scott Gray-2
On 10/03/2010, at 10:35 AM, Adam Heath wrote:

> Scott Gray wrote:
>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>
>>> [hidden email] wrote:
>>>> Author: jleroux
>>>> Date: Wed Mar 10 16:12:30 2010
>>>> New Revision: 921421
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>> Log:
>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>
>>>> Modified:
>>>>   ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>
>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>> @@ -97,7 +97,7 @@
>>>>    </property>
>>>>    <property key="ExampleDateField10Tooltip">
>>>>        <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>        <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>        <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>    </property>
>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>> characters, like < or > or &.
>>
>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>> tooltip = encode(tooltip, modelFormField, context);
>
> That's what I mean, I went and looked at the method he referenced, to
> know what the variable name was.
>
> I also looked at the macro files themselves, and they will work if
> passed this encoded string value.
>
> However, from a perfectionist standpoint, it doesn't sit well with me.
> What happens if these macros use a string from a map, that is already
> encoded, then try to double-encode it?
It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.

> Ideally, MacroFormRenderer is calling freemarker.  So it should use
> freemarker encodings of special characters.  Freemarker should then
> decode said special markup, so that the macros it ends up calling can
> do what they need for it.

Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.

Regards
Scott


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
Scott Gray wrote:

> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>
>> Scott Gray wrote:
>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>
>>>> [hidden email] wrote:
>>>>> Author: jleroux
>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>> New Revision: 921421
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>> Log:
>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>
>>>>> Modified:
>>>>>   ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>
>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>> ==============================================================================
>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>> @@ -97,7 +97,7 @@
>>>>>    </property>
>>>>>    <property key="ExampleDateField10Tooltip">
>>>>>        <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>        <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>        <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>    </property>
>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>> characters, like < or > or &.
>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>> tooltip = encode(tooltip, modelFormField, context);
>> That's what I mean, I went and looked at the method he referenced, to
>> know what the variable name was.
>>
>> I also looked at the macro files themselves, and they will work if
>> passed this encoded string value.
>>
>> However, from a perfectionist standpoint, it doesn't sit well with me.
>> What happens if these macros use a string from a map, that is already
>> encoded, then try to double-encode it?
>
> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>
>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>> freemarker encodings of special characters.  Freemarker should then
>> decode said special markup, so that the macros it ends up calling can
>> do what they need for it.
>
> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.

Finall output encoding is not the same as encoding when it leaves your
control.

A -> B -> C -> D

A needs to encode it's output to get around any issues that B has.
Then B needs decode it's input, and then encode it's output as it
passes to C.  And so on, and so on.

The real problem here is using strings to pass data around.  It should
be passed as part of the context.

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Jacopo Cappellato-4

On Mar 10, 2010, at 7:03 PM, Adam Heath wrote:

> Scott Gray wrote:
>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>
>>> Scott Gray wrote:
>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>
>>>>> [hidden email] wrote:
>>>>>> Author: jleroux
>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>> New Revision: 921421
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>> Log:
>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>
>>>>>> Modified:
>>>>>>  ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>> @@ -97,7 +97,7 @@
>>>>>>   </property>
>>>>>>   <property key="ExampleDateField10Tooltip">
>>>>>>       <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>       <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>       <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>   </property>
>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>> characters, like < or > or &.
>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>> tooltip = encode(tooltip, modelFormField, context);
>>> That's what I mean, I went and looked at the method he referenced, to
>>> know what the variable name was.
>>>
>>> I also looked at the macro files themselves, and they will work if
>>> passed this encoded string value.
>>>
>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>> What happens if these macros use a string from a map, that is already
>>> encoded, then try to double-encode it?
>>
>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>
>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>> freemarker encodings of special characters.  Freemarker should then
>>> decode said special markup, so that the macros it ends up calling can
>>> do what they need for it.
>>
>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>
> Finall output encoding is not the same as encoding when it leaves your
> control.
>
> A -> B -> C -> D
>
> A needs to encode it's output to get around any issues that B has.
> Then B needs decode it's input, and then encode it's output as it
> passes to C.  And so on, and so on.
>
> The real problem here is using strings to pass data around.  It should
> be passed as part of the context.
>

Of course, this is the reason fwe have to encode!

Jacopo


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Jacques Le Roux
Administrator
In reply to this post by Adam Heath-2
From: "Adam Heath" <[hidden email]>

> [hidden email] wrote:
>> Author: jleroux
>> Date: Wed Mar 10 16:12:30 2010
>> New Revision: 921421
>>
>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>> Log:
>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave
>> up, too narrow need.
>>
>> Modified:
>>     ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>
>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>> @@ -97,7 +97,7 @@
>>      </property>
>>      <property key="ExampleDateField10Tooltip">
>>          <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the
>> default value to now</value>
>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour
>> affecter la valeur par défaut à  "maintenant"</value>
>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour
>> affecter la valeur par défaut à  'maintenant'</value>
>>          <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form)
>> per impostare il valore di default ad adesso</value>
>>          <value xml:lang="zh">同上,使用nowTimstamp变量(在表单中总是可用的)来把缺省值设置为现在</value>
>>      </property>
>
> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
> characters, like < or > or &.

In UtilHttp.java I tried to create (and use in appendTooltip)
public static String encodeQuotes(String htmlString) {
return htmlString.replaceAll("\"", "%34");
}

Mimicking encodeBlanks, but it did not works as we have to distinguish between quote around the tooltip and inside the tooltip. I
don't think your suggestion will write either, I will try though

> Additionally, appendTooltip should not be using a StringWriter.

I agree about that point

Jacques

>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Scott Gray-2
In reply to this post by Adam Heath-2
On 10/03/2010, at 11:03 AM, Adam Heath wrote:

> Scott Gray wrote:
>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>
>>> Scott Gray wrote:
>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>
>>>>> [hidden email] wrote:
>>>>>> Author: jleroux
>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>> New Revision: 921421
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>> Log:
>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>
>>>>>> Modified:
>>>>>>  ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>> @@ -97,7 +97,7 @@
>>>>>>   </property>
>>>>>>   <property key="ExampleDateField10Tooltip">
>>>>>>       <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>       <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>       <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>   </property>
>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>> characters, like < or > or &.
>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>> tooltip = encode(tooltip, modelFormField, context);
>>> That's what I mean, I went and looked at the method he referenced, to
>>> know what the variable name was.
>>>
>>> I also looked at the macro files themselves, and they will work if
>>> passed this encoded string value.
>>>
>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>> What happens if these macros use a string from a map, that is already
>>> encoded, then try to double-encode it?
>>
>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>
>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>> freemarker encodings of special characters.  Freemarker should then
>>> decode said special markup, so that the macros it ends up calling can
>>> do what they need for it.
>>
>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>
> Finall output encoding is not the same as encoding when it leaves your
> control.
>
> A -> B -> C -> D
>
> A needs to encode it's output to get around any issues that B has.
> Then B needs decode it's input, and then encode it's output as it
> passes to C.  And so on, and so on.
>
> The real problem here is using strings to pass data around.  It should
> be passed as part of the context.
You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
Multiple encoding/decoding points just seems like it will add unnecessary complexity.

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adrian Crum
Scott Gray wrote:

> On 10/03/2010, at 11:03 AM, Adam Heath wrote:
>
>> Scott Gray wrote:
>>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>>
>>>> Scott Gray wrote:
>>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>>
>>>>>> [hidden email] wrote:
>>>>>>> Author: jleroux
>>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>>> New Revision: 921421
>>>>>>>
>>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>>> Log:
>>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>>
>>>>>>> Modified:
>>>>>>>  ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>
>>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>>> ==============================================================================
>>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>>> @@ -97,7 +97,7 @@
>>>>>>>   </property>
>>>>>>>   <property key="ExampleDateField10Tooltip">
>>>>>>>       <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>>       <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>>       <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>>   </property>
>>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>>> characters, like < or > or &.
>>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>>> tooltip = encode(tooltip, modelFormField, context);
>>>> That's what I mean, I went and looked at the method he referenced, to
>>>> know what the variable name was.
>>>>
>>>> I also looked at the macro files themselves, and they will work if
>>>> passed this encoded string value.
>>>>
>>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>>> What happens if these macros use a string from a map, that is already
>>>> encoded, then try to double-encode it?
>>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>>
>>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>>> freemarker encodings of special characters.  Freemarker should then
>>>> decode said special markup, so that the macros it ends up calling can
>>>> do what they need for it.
>>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>> Finall output encoding is not the same as encoding when it leaves your
>> control.
>>
>> A -> B -> C -> D
>>
>> A needs to encode it's output to get around any issues that B has.
>> Then B needs decode it's input, and then encode it's output as it
>> passes to C.  And so on, and so on.
>>
>> The real problem here is using strings to pass data around.  It should
>> be passed as part of the context.
>
> You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
> Multiple encoding/decoding points just seems like it will add unnecessary complexity.

Stronger data typing is much easier to use in the long run. The problem
with passing data around in Strings is you don't know what the String
contains. Is it plain text? HTML? XML? Encoded? Decoded?
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
In reply to this post by Scott Gray-2
Scott Gray wrote:

> On 10/03/2010, at 11:03 AM, Adam Heath wrote:
>
>> Scott Gray wrote:
>>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>>
>>>> Scott Gray wrote:
>>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>>
>>>>>> [hidden email] wrote:
>>>>>>> Author: jleroux
>>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>>> New Revision: 921421
>>>>>>>
>>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>>> Log:
>>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>>
>>>>>>> Modified:
>>>>>>>  ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>
>>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>>> ==============================================================================
>>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>>> @@ -97,7 +97,7 @@
>>>>>>>   </property>
>>>>>>>   <property key="ExampleDateField10Tooltip">
>>>>>>>       <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>>       <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>>       <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>>   </property>
>>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>>> characters, like < or > or &.
>>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>>> tooltip = encode(tooltip, modelFormField, context);
>>>> That's what I mean, I went and looked at the method he referenced, to
>>>> know what the variable name was.
>>>>
>>>> I also looked at the macro files themselves, and they will work if
>>>> passed this encoded string value.
>>>>
>>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>>> What happens if these macros use a string from a map, that is already
>>>> encoded, then try to double-encode it?
>>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>>
>>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>>> freemarker encodings of special characters.  Freemarker should then
>>>> decode said special markup, so that the macros it ends up calling can
>>>> do what they need for it.
>>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>> Finall output encoding is not the same as encoding when it leaves your
>> control.
>>
>> A -> B -> C -> D
>>
>> A needs to encode it's output to get around any issues that B has.
>> Then B needs decode it's input, and then encode it's output as it
>> passes to C.  And so on, and so on.
>>
>> The real problem here is using strings to pass data around.  It should
>> be passed as part of the context.
>
> You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
> Multiple encoding/decoding points just seems like it will add unnecessary complexity.

Each stage of the rendering pipline needs to allow it's caller to
encode things as input.  Then, the stage has to decode these incoming
parameters for it's internal use, then encode them again for the next
stage.

It's not just that each rendering stage has to encode for it's output.
 But the incoming has to be encoded to pass whatever requirements are
nescessary for the stage.

If you are still having problems understanding what I am saying, then
ask, and I'll give a more concrete example.


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Jacques Le Roux
Administrator
In reply to this post by Adam Heath-2
From: "Adam Heath" <[hidden email]>

> Scott Gray wrote:
>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>
>>> Scott Gray wrote:
>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>
>>>>> [hidden email] wrote:
>>>>>> Author: jleroux
>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>> New Revision: 921421
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>> Log:
>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but
>>>>>> gave up, too narrow need.
>>>>>>
>>>>>> Modified:
>>>>>>   ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>> @@ -97,7 +97,7 @@
>>>>>>    </property>
>>>>>>    <property key="ExampleDateField10Tooltip">
>>>>>>        <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the
>>>>>> default value to now</value>
>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée
>>>>>> pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée
>>>>>> pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>        <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form)
>>>>>> per impostare il valore di default ad adesso</value>
>>>>>>        <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>    </property>
>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>> characters, like < or > or &.

I agree about other weird characters but not for the double quote case.
If you like at it closer you will see that it's not an encoding issue.
Because we have to distinguish between quote around the tooltip and inside the tooltip.


>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that
>>>> all over.
>>>> tooltip = encode(tooltip, modelFormField, context);

It's not the same case


>>> That's what I mean, I went and looked at the method he referenced, to
>>> know what the variable name was.
>>>
>>> I also looked at the macro files themselves, and they will work if
>>> passed this encoded string value.

Did you try? You will get something like
2010-03-10 19:32:05,375 (http-0.0.0.0-8443-6) [  MacroFormRenderer.java:135:ERROR]
---- exception report ----------------------------------------------------------
Error rendering screen thru ftl
Exception: freemarker.core.ParseException
Message: Encountered "%" at line 1, column 25 in Wed Mar 10 19:32:05 CET 2010.
Was expecting one of:
    <STRING_LITERAL> ...
    <RAW_STRING> ...
    "false" ...
    "true" ...
    <INTEGER> ...
    <DECIMAL> ...
    "." ...
    "+" ...
    "-" ...
    "!" ...
    "[" ...
    "(" ...
    "{" ...
    <ID> ...


>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>> What happens if these macros use a string from a map, that is already
>>> encoded, then try to double-encode it?

That's the problem I crossed in r921401

>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as
>> possible encoding strategy is definitely the way to go.
>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>> freemarker encodings of special characters.  Freemarker should then
>>> decode said special markup, so that the macros it ends up calling can
>>> do what they need for it.
>>
>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings
>> we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField,
>> requires us to update all the other form renderers before we can remove them.

Yes, I agree with that, but IMO it's a delicate issue. A bit like the work you did for BigDecimal, maybe harder because there are
different cases, maybe not because these cases are possibly the same all over.

Jacques

> Finall output encoding is not the same as encoding when it leaves your
> control.
>
> A -> B -> C -> D
>
> A needs to encode it's output to get around any issues that B has.
> Then B needs decode it's input, and then encode it's output as it
> passes to C.  And so on, and so on.
>
> The real problem here is using strings to pass data around.  It should
> be passed as part of the context.
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
In reply to this post by Jacques Le Roux
Jacques Le Roux wrote:
>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>> characters, like < or > or &.
>
> In UtilHttp.java I tried to create (and use in appendTooltip)
> public static String encodeQuotes(String htmlString) {
> return htmlString.replaceAll("\"", "%34");
> }

That's the wrong encoding, &quot;

You are encoding for request parameters, what you need to do is encode
for xml/html content.

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Scott Gray-2
In reply to this post by Adam Heath-2
On 10/03/2010, at 11:39 AM, Adam Heath wrote:

> Scott Gray wrote:
>> On 10/03/2010, at 11:03 AM, Adam Heath wrote:
>>
>>> Scott Gray wrote:
>>>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>>>
>>>>> Scott Gray wrote:
>>>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>>>
>>>>>>> [hidden email] wrote:
>>>>>>>> Author: jleroux
>>>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>>>> New Revision: 921421
>>>>>>>>
>>>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>>>> Log:
>>>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>> ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>>
>>>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>>>> ==============================================================================
>>>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>>>> @@ -97,7 +97,7 @@
>>>>>>>>  </property>
>>>>>>>>  <property key="ExampleDateField10Tooltip">
>>>>>>>>      <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>>>      <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>>>      <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>>>  </property>
>>>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>>>> characters, like < or > or &.
>>>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>>>> tooltip = encode(tooltip, modelFormField, context);
>>>>> That's what I mean, I went and looked at the method he referenced, to
>>>>> know what the variable name was.
>>>>>
>>>>> I also looked at the macro files themselves, and they will work if
>>>>> passed this encoded string value.
>>>>>
>>>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>>>> What happens if these macros use a string from a map, that is already
>>>>> encoded, then try to double-encode it?
>>>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>>>
>>>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>>>> freemarker encodings of special characters.  Freemarker should then
>>>>> decode said special markup, so that the macros it ends up calling can
>>>>> do what they need for it.
>>>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>>> Finall output encoding is not the same as encoding when it leaves your
>>> control.
>>>
>>> A -> B -> C -> D
>>>
>>> A needs to encode it's output to get around any issues that B has.
>>> Then B needs decode it's input, and then encode it's output as it
>>> passes to C.  And so on, and so on.
>>>
>>> The real problem here is using strings to pass data around.  It should
>>> be passed as part of the context.
>>
>> You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
>> Multiple encoding/decoding points just seems like it will add unnecessary complexity.
>
> Each stage of the rendering pipline needs to allow it's caller to
> encode things as input.  Then, the stage has to decode these incoming
> parameters for it's internal use, then encode them again for the next
> stage.
Pipeline? What pipeline?  We only have two things, a model and a renderer.  The model should be concerned with encoding, it should deal with raw unencoded strings.  The renderer should encode data just before it outputs it.

> It's not just that each rendering stage has to encode for it's output.
> But the incoming has to be encoded to pass whatever requirements are
> nescessary for the stage.

I still only consider there to be one stage: take the model and render it.  The model doesn't have any output, it's a model.

> If you are still having problems understanding what I am saying, then
> ask, and I'll give a more concrete example.

That would be great.

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Scott Gray-2
In reply to this post by Adrian Crum
On 10/03/2010, at 11:37 AM, Adrian Crum wrote:

> Scott Gray wrote:
>> On 10/03/2010, at 11:03 AM, Adam Heath wrote:
>>> Scott Gray wrote:
>>>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>>>
>>>>> Scott Gray wrote:
>>>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>>>
>>>>>>> [hidden email] wrote:
>>>>>>>> Author: jleroux
>>>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>>>> New Revision: 921421
>>>>>>>>
>>>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>>>> Log:
>>>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>> ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>>
>>>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>>>> ==============================================================================
>>>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>>>> @@ -97,7 +97,7 @@
>>>>>>>>  </property>
>>>>>>>>  <property key="ExampleDateField10Tooltip">
>>>>>>>>      <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>>>      <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>>>      <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>>>  </property>
>>>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>>>> characters, like < or > or &.
>>>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>>>> tooltip = encode(tooltip, modelFormField, context);
>>>>> That's what I mean, I went and looked at the method he referenced, to
>>>>> know what the variable name was.
>>>>>
>>>>> I also looked at the macro files themselves, and they will work if
>>>>> passed this encoded string value.
>>>>>
>>>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>>>> What happens if these macros use a string from a map, that is already
>>>>> encoded, then try to double-encode it?
>>>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>>>
>>>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>>>> freemarker encodings of special characters.  Freemarker should then
>>>>> decode said special markup, so that the macros it ends up calling can
>>>>> do what they need for it.
>>>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>>> Finall output encoding is not the same as encoding when it leaves your
>>> control.
>>>
>>> A -> B -> C -> D
>>>
>>> A needs to encode it's output to get around any issues that B has.
>>> Then B needs decode it's input, and then encode it's output as it
>>> passes to C.  And so on, and so on.
>>>
>>> The real problem here is using strings to pass data around.  It should
>>> be passed as part of the context.
>> You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
>> Multiple encoding/decoding points just seems like it will add unnecessary complexity.
>
> Stronger data typing is much easier to use in the long run. The problem with passing data around in Strings is you don't know what the String contains. Is it plain text? HTML? XML? Encoded? Decoded?
All raw data being passed around should be plain text, encode it when you pass it out to the response.  I still don't see the need for any complexity.


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
From: "Jacques Le Roux" <[hidden email]>

> From: "Adam Heath" <[hidden email]>
>> [hidden email] wrote:
>>> Author: jleroux
>>> Date: Wed Mar 10 16:12:30 2010
>>> New Revision: 921421
>>>
>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>> Log:
>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave
>>> up, too narrow need.
>>>
>>> Modified:
>>>     ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>
>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>> @@ -97,7 +97,7 @@
>>>      </property>
>>>      <property key="ExampleDateField10Tooltip">
>>>          <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the
>>> default value to now</value>
>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour
>>> affecter la valeur par défaut à  "maintenant"</value>
>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour
>>> affecter la valeur par défaut à  'maintenant'</value>
>>>          <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form)
>>> per impostare il valore di default ad adesso</value>
>>>          <value
>>> xml:lang="zh">同上,使用nowTimstamp变量(在表单中总是可用的)来把缺省值设置为现在</value>
>>>      </property>
>>
>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>> characters, like < or > or &.
>
> In UtilHttp.java I tried to create (and use in appendTooltip)
> public static String encodeQuotes(String htmlString) {
> return htmlString.replaceAll("\"", "%34");
> }
>
> Mimicking encodeBlanks, but it did not works as we have to distinguish between quote around the tooltip and inside the tooltip. I
> don't think your suggestion will write either, I will try though
>
>> Additionally, appendTooltip should not be using a StringWriter.
>
> I agree about that point

I agree but then we have to change all render method there. I think you would prefer a StringBuilder but what is exactly the
difference in these cases? Because we don't need streams, only strings?

Thanks

Ja cques

> Jacques


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Jacques Le Roux
Administrator
In reply to this post by Adam Heath-2
From: "Adam Heath" <[hidden email]>

> Jacques Le Roux wrote:
>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>> characters, like < or > or &.
>>
>> In UtilHttp.java I tried to create (and use in appendTooltip)
>> public static String encodeQuotes(String htmlString) {
>> return htmlString.replaceAll("\"", "%34");
>> }
>
> That's the wrong encoding, &quot;
>
> You are encoding for request parameters, what you need to do is encode
> for xml/html content.

As I said it's not the problem, try...

Jacques

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
In reply to this post by Scott Gray-2
Scott Gray wrote:

> On 10/03/2010, at 11:39 AM, Adam Heath wrote:
>
>> Scott Gray wrote:
>>> On 10/03/2010, at 11:03 AM, Adam Heath wrote:
>>>
>>>> Scott Gray wrote:
>>>>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>>>>
>>>>>> Scott Gray wrote:
>>>>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>>>>
>>>>>>>> [hidden email] wrote:
>>>>>>>>> Author: jleroux
>>>>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>>>>> New Revision: 921421
>>>>>>>>>
>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>>>>> Log:
>>>>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>>>>
>>>>>>>>> Modified:
>>>>>>>>> ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>>>
>>>>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>>>>> ==============================================================================
>>>>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>>>>> @@ -97,7 +97,7 @@
>>>>>>>>>  </property>
>>>>>>>>>  <property key="ExampleDateField10Tooltip">
>>>>>>>>>      <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>>>>      <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>>>>      <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>>>>  </property>
>>>>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>>>>> characters, like < or > or &.
>>>>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>>>>> tooltip = encode(tooltip, modelFormField, context);
>>>>>> That's what I mean, I went and looked at the method he referenced, to
>>>>>> know what the variable name was.
>>>>>>
>>>>>> I also looked at the macro files themselves, and they will work if
>>>>>> passed this encoded string value.
>>>>>>
>>>>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>>>>> What happens if these macros use a string from a map, that is already
>>>>>> encoded, then try to double-encode it?
>>>>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>>>>
>>>>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>>>>> freemarker encodings of special characters.  Freemarker should then
>>>>>> decode said special markup, so that the macros it ends up calling can
>>>>>> do what they need for it.
>>>>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>>>> Finall output encoding is not the same as encoding when it leaves your
>>>> control.
>>>>
>>>> A -> B -> C -> D
>>>>
>>>> A needs to encode it's output to get around any issues that B has.
>>>> Then B needs decode it's input, and then encode it's output as it
>>>> passes to C.  And so on, and so on.
>>>>
>>>> The real problem here is using strings to pass data around.  It should
>>>> be passed as part of the context.
>>> You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
>>> Multiple encoding/decoding points just seems like it will add unnecessary complexity.
>> Each stage of the rendering pipline needs to allow it's caller to
>> encode things as input.  Then, the stage has to decode these incoming
>> parameters for it's internal use, then encode them again for the next
>> stage.
>
> Pipeline? What pipeline?  We only have two things, a model and a renderer.  The model should be concerned with encoding, it should deal with raw unencoded strings.  The renderer should encode data just before it outputs it.
>
>> It's not just that each rendering stage has to encode for it's output.
>> But the incoming has to be encoded to pass whatever requirements are
>> nescessary for the stage.
>
> I still only consider there to be one stage: take the model and render it.  The model doesn't have any output, it's a model.

There-in lies the problem.

The model exists as plain objects.  But then MacroFormRender starts.
This is stage one.  It has to encode for freemarker to be able to
parse it.

Stage two is when freemarker runs, and finally outputs html.

Stage one is encoding the parameters as strings.  It needs to be able
to allow freemarker to parse it, while getting the actual real value.
 Freemarker is xml-like, so xml encoding should be used.  Of course,
not doing any encoding at all in stage one would be better.

In stage two, freemarker will parse the raw text, converting it
internally to objects in the macro call.  The final called macro has
to then encode it properly for the final output, maybe html, maybe
csv, maybe xml/pdf or something.


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
From: "Jacques Le Roux" <[hidden email]>

> From: "Adam Heath" <[hidden email]>
>> Jacques Le Roux wrote:
>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>> characters, like < or > or &.
>>>
>>> In UtilHttp.java I tried to create (and use in appendTooltip)
>>> public static String encodeQuotes(String htmlString) {
>>> return htmlString.replaceAll("\"", "%34");
>>> }
>>
>> That's the wrong encoding, &quot;
>>
>> You are encoding for request parameters, what you need to do is encode
>> for xml/html content.
>
> As I said it's not the problem, try...

The reason is that, yes you want to encode for xhtml, but you have Freemarker in the middle...

Jacques
 
> Jacques
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Scott Gray-2
In reply to this post by Adam Heath-2
On 10/03/2010, at 12:00 PM, Adam Heath wrote:

> Scott Gray wrote:
>> On 10/03/2010, at 11:39 AM, Adam Heath wrote:
>>
>>> Scott Gray wrote:
>>>> On 10/03/2010, at 11:03 AM, Adam Heath wrote:
>>>>
>>>>> Scott Gray wrote:
>>>>>> On 10/03/2010, at 10:35 AM, Adam Heath wrote:
>>>>>>
>>>>>>> Scott Gray wrote:
>>>>>>>> On 10/03/2010, at 9:48 AM, Adam Heath wrote:
>>>>>>>>
>>>>>>>>> [hidden email] wrote:
>>>>>>>>>> Author: jleroux
>>>>>>>>>> Date: Wed Mar 10 16:12:30 2010
>>>>>>>>>> New Revision: 921421
>>>>>>>>>>
>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=921421&view=rev
>>>>>>>>>> Log:
>>>>>>>>>> You can't use double quote in tooltips. I tried to find a quick way to allow this in MacroFormRenderer.appendTooltip() but gave up, too narrow need.
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>>> ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>>>>
>>>>>>>>>> Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
>>>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=921421&r1=921420&r2=921421&view=diff
>>>>>>>>>> ==============================================================================
>>>>>>>>>> --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
>>>>>>>>>> +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Wed Mar 10 16:12:30 2010
>>>>>>>>>> @@ -97,7 +97,7 @@
>>>>>>>>>> </property>
>>>>>>>>>> <property key="ExampleDateField10Tooltip">
>>>>>>>>>>     <value xml:lang="en">Same as above, uses the nowTimestamp variable (always available in the form context) to set the default value to now</value>
>>>>>>>>>> -        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  "maintenant"</value>
>>>>>>>>>> +        <value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour affecter la valeur par défaut à  'maintenant'</value>
>>>>>>>>>>     <value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per impostare il valore di default ad adesso</value>
>>>>>>>>>>     <value xml:lang="zh">同上,使用nowTimstamp变量(åœ¨è¡¨å•ä¸ æ€»æ˜¯å¯ç”¨çš„)来把缺省值设置为现在</value>
>>>>>>>>>> </property>
>>>>>>>>> tooltip.replaceAll("\"", "&quot;"), also handling any other weird html
>>>>>>>>> characters, like < or > or &.
>>>>>>>> It would probably be easiest to just encode the tooltip string before generating the macro call.  There are examples of that all over.
>>>>>>>> tooltip = encode(tooltip, modelFormField, context);
>>>>>>> That's what I mean, I went and looked at the method he referenced, to
>>>>>>> know what the variable name was.
>>>>>>>
>>>>>>> I also looked at the macro files themselves, and they will work if
>>>>>>> passed this encoded string value.
>>>>>>>
>>>>>>> However, from a perfectionist standpoint, it doesn't sit well with me.
>>>>>>> What happens if these macros use a string from a map, that is already
>>>>>>> encoded, then try to double-encode it?
>>>>>> It shouldn't be encoded until it is about to be rendered, ModelFormField.getEntry(...) encodes early and it is a PITA.  A late as possible encoding strategy is definitely the way to go.
>>>>>>
>>>>>>> Ideally, MacroFormRenderer is calling freemarker.  So it should use
>>>>>>> freemarker encodings of special characters.  Freemarker should then
>>>>>>> decode said special markup, so that the macros it ends up calling can
>>>>>>> do what they need for it.
>>>>>> Agreed, allowing freemarker to do the encoding would certainly be easier but until we get rid of ALL of the earlier encodings we'll end up with double encoding.  Also any encoding that takes place outside of the renderer methods, like in ModelFormField, requires us to update all the other form renderers before we can remove them.
>>>>> Finall output encoding is not the same as encoding when it leaves your
>>>>> control.
>>>>>
>>>>> A -> B -> C -> D
>>>>>
>>>>> A needs to encode it's output to get around any issues that B has.
>>>>> Then B needs decode it's input, and then encode it's output as it
>>>>> passes to C.  And so on, and so on.
>>>>>
>>>>> The real problem here is using strings to pass data around.  It should
>>>>> be passed as part of the context.
>>>> You've lost me, IMO each renderer should be responsible for handling the encoding required of the output it's generating.
>>>> Multiple encoding/decoding points just seems like it will add unnecessary complexity.
>>> Each stage of the rendering pipline needs to allow it's caller to
>>> encode things as input.  Then, the stage has to decode these incoming
>>> parameters for it's internal use, then encode them again for the next
>>> stage.
>>
>> Pipeline? What pipeline?  We only have two things, a model and a renderer.  The model should be concerned with encoding, it should deal with raw unencoded strings.  The renderer should encode data just before it outputs it.
>>
>>> It's not just that each rendering stage has to encode for it's output.
>>> But the incoming has to be encoded to pass whatever requirements are
>>> nescessary for the stage.
>>
>> I still only consider there to be one stage: take the model and render it.  The model doesn't have any output, it's a model.
>
> There-in lies the problem.
>
> The model exists as plain objects.  But then MacroFormRender starts.
> This is stage one.  It has to encode for freemarker to be able to
> parse it.
>
> Stage two is when freemarker runs, and finally outputs html.
>
> Stage one is encoding the parameters as strings.  It needs to be able
> to allow freemarker to parse it, while getting the actual real value.
> Freemarker is xml-like, so xml encoding should be used.  Of course,
> not doing any encoding at all in stage one would be better.
>
> In stage two, freemarker will parse the raw text, converting it
> internally to objects in the macro call.  The final called macro has
> to then encode it properly for the final output, maybe html, maybe
> csv, maybe xml/pdf or something.
The only actual encoding required by freemarker is that we escape double quotes because we use them to enclose the parameters in the macro calls and also backslashes.  There is no need to use xml encoding and no need to decode the escaping because freemarker does that automatically.

From http://freemarker.sourceforge.net/docs/dgui_template_exp.html#dgui_template_exp_direct_string
"If the text itself contains the character used for the quoting (either " or ') or backslashes, you have to precede them with a backslash; this is called escaping. You can type any other character, including line breaks, in the text directly."

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r921421 - /ofbiz/trunk/framework/example/config/ExampleUiLabels.xml

Adam Heath-2
Scott Gray wrote:
> The only actual encoding required by freemarker is that we escape double quotes because we use them to enclose the parameters in the macro calls and also backslashes.  There is no need to use xml encoding and no need to decode the escaping because freemarker does that automatically.
>
> From http://freemarker.sourceforge.net/docs/dgui_template_exp.html#dgui_template_exp_direct_string
> "If the text itself contains the character used for the quoting (either " or ') or backslashes, you have to precede them with a backslash; this is called escaping. You can type any other character, including line breaks, in the text directly."

The real problem is executeMacro in that same class, it shouldn't be
doing things as a string, but instead looking up the requested macro
and executing it directly.

investigating...
12