Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-6504

how to Create PDF with password Protected in Ofbiz

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 16.11.01
    • Component/s: ALL APPLICATIONS
    • Labels:
      None
    • Environment:

      linux

      Description

      We can create PDF using FTL that is OK, but how to generate PDF with Encryption password protected?
      itext is best option for this. but can we emmber in ftl or other places?
      pleas Help us.

      1. localhost.png
        61 kB
        Jacques Le Roux
      2. trunk demo.png
        64 kB
        Jacques Le Roux

        Issue Links

          Activity

          Hide
          shi.jinghai Shi Jinghai added a comment -

          Sachin,

          In OFBiz, we use FOP to generate PDF, that's the way you mentioned above, by FTL. AFAIK, FOP can use password to protect PDF, so it's unnecessary to introduce itext.

          I'll try to add a example to support this function.

          Show
          shi.jinghai Shi Jinghai added a comment - Sachin, In OFBiz, we use FOP to generate PDF, that's the way you mentioned above, by FTL. AFAIK, FOP can use password to protect PDF, so it's unnecessary to introduce itext. I'll try to add a example to support this function.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Sachin,

          The function you required is in trunk rev. 1690515. Please be aware, there are two passwords for a PDF, owner password and user password.

          When visiting https://localhost:8443/example/control/EditExample?exampleId=EX01, there's a new button called "PDF With Password", click it and then you can input your password to a PDF generated by FOP and PDFBox.

          There's a new examplepdf.properties under specialpurpose/example/config/. You can use it to config what the passwords will be.

          The password in encrypted by PDFBox, it is a project in Apache foundation. The bcprov-jdk15-1.44.jar is a runtime library required by PDFBox 1.7.1 to encrypt a PDF.

          Show
          shi.jinghai Shi Jinghai added a comment - Sachin, The function you required is in trunk rev. 1690515. Please be aware, there are two passwords for a PDF, owner password and user password. When visiting https://localhost:8443/example/control/EditExample?exampleId=EX01 , there's a new button called "PDF With Password", click it and then you can input your password to a PDF generated by FOP and PDFBox. There's a new examplepdf.properties under specialpurpose/example/config/. You can use it to config what the passwords will be. The password in encrypted by PDFBox, it is a project in Apache foundation. The bcprov-jdk15-1.44.jar is a runtime library required by PDFBox 1.7.1 to encrypt a PDF.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          I'll try to use the native FOP encrypt method to create PDF with password, see:
          http://xmlgraphics.apache.org/fop/trunk/pdfencryption.html

          As it's FOP 1.1 in OFBiz trunk, I checked FOP 1.1 source code, it supports these encrypt methods.

          I'll remove the bcprov-jdk15-1.44.jar as well.

          Show
          shi.jinghai Shi Jinghai added a comment - I'll try to use the native FOP encrypt method to create PDF with password, see: http://xmlgraphics.apache.org/fop/trunk/pdfencryption.html As it's FOP 1.1 in OFBiz trunk, I checked FOP 1.1 source code, it supports these encrypt methods. I'll remove the bcprov-jdk15-1.44.jar as well.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Yesterday, I tried the FOP 1.1 native encryption in OFBiz trunk and failed. I found FOP 2.0 encryption is quite different to FOP 1.1. FOP 2.0 encryption works on my environment well, but the changes are quite a lot.

          FOP 1.1:
          http://xmlgraphics.apache.org/fop/1.1/pdfencryption.html#Environment

          FOP 2.0:
          http://xmlgraphics.apache.org/fop/2.0/pdfencryption.html#Environment

          I need some advices on whether to upgrade to FOP 2.0 in OFBiz trunk.

          Show
          shi.jinghai Shi Jinghai added a comment - Yesterday, I tried the FOP 1.1 native encryption in OFBiz trunk and failed. I found FOP 2.0 encryption is quite different to FOP 1.1. FOP 2.0 encryption works on my environment well, but the changes are quite a lot. FOP 1.1: http://xmlgraphics.apache.org/fop/1.1/pdfencryption.html#Environment FOP 2.0: http://xmlgraphics.apache.org/fop/2.0/pdfencryption.html#Environment I need some advices on whether to upgrade to FOP 2.0 in OFBiz trunk.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          1. Changed to use FOP 2.0 native encryption, jars are updated.

          2. Now the Embeded options are request parameters supported in ScreenFopViewHandler.java, the options are:
          http://xmlgraphics.apache.org/fop/2.0/pdfencryption.html#embedded
          the default values of the options can be configured in framework/webapp/config/fop.properties.

          3. The demo page is https://localhost:8443/example/control/ExampleReportPdfOptions?exampleId=EX01

          4. Barcode is tested.

          Show
          shi.jinghai Shi Jinghai added a comment - 1. Changed to use FOP 2.0 native encryption, jars are updated. 2. Now the Embeded options are request parameters supported in ScreenFopViewHandler.java, the options are: http://xmlgraphics.apache.org/fop/2.0/pdfencryption.html#embedded the default values of the options can be configured in framework/webapp/config/fop.properties. 3. The demo page is https://localhost:8443/example/control/ExampleReportPdfOptions?exampleId=EX01 4. Barcode is tested.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          In trunk rev. 1691852.

          Show
          shi.jinghai Shi Jinghai added a comment - In trunk rev. 1691852.
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Hi Jinghai,

          When I try locally and on trunk demo I get this error for both the normal PDF and the one with password:

          Unable to transform FO file: org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: null:79:113: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 79:113) javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: null:79:113: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 79:113)
          

          Do I miss something?

          Show
          jacques.le.roux Jacques Le Roux added a comment - Hi Jinghai, When I try locally and on trunk demo I get this error for both the normal PDF and the one with password: Unable to transform FO file: org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: null :79:113: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 79:113) javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: null :79:113: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 79:113) Do I miss something?
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Ha also Jinghai, in most case the committer who fixes the bug or does the work close the Jira himself. In some specific case you may ask the reporter or contributor to close himself after checking it's OK with him

          Show
          jacques.le.roux Jacques Le Roux added a comment - Ha also Jinghai, in most case the committer who fixes the bug or does the work close the Jira himself. In some specific case you may ask the reporter or contributor to close himself after checking it's OK with him
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Yeah I see, a check step. I'll be care of this.

          Show
          shi.jinghai Shi Jinghai added a comment - Yeah I see, a check step. I'll be care of this.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Hi Jacques,

          I don't know what's the reason of this error (a cache problem I guess). I just tested here:
          http://demo-trunk-ofbiz.apache.org/example/control/ExampleReportPdfOptions?exampleId=EX01

          and it works.

          Show
          shi.jinghai Shi Jinghai added a comment - Hi Jacques, I don't know what's the reason of this error (a cache problem I guess). I just tested here: http://demo-trunk-ofbiz.apache.org/example/control/ExampleReportPdfOptions?exampleId=EX01 and it works.
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          I tried again, either on FF or Chrome I have still the same error on both localhost and trunk demo

          Show
          jacques.le.roux Jacques Le Roux added a comment - I tried again, either on FF or Chrome I have still the same error on both localhost and trunk demo
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Thank you Jacques for the screenshots!

          They are very helpful, I can reproduce it with fr locale. Some other locales I tested are fine (no error message displayed), i.e. en, zh, de, nl, ja.

          I reopen this issue and I'll try to see what's the reason behind.

          Show
          shi.jinghai Shi Jinghai added a comment - Thank you Jacques for the screenshots! They are very helpful, I can reproduce it with fr locale. Some other locales I tested are fine (no error message displayed), i.e. en, zh, de, nl, ja. I reopen this issue and I'll try to see what's the reason behind.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Hi Jacques,

          When locale is fr, the error message in error.log is:

          http-bio-8443-exec-1 MacroFormRenderer E Error rendering screen thru ftl, macro: <@renderDropDownField name="statusId" className="required" alert="false" id="EditExample_statusId" multiple="" formName="EditExample" otherFieldName="" event="" action="" size="1" firstInList="first-in-list" currentValue="EXST_DEFINED" explicitDescription="Paramétré" allowEmpty="" options=[{'key':'EXST_APPROVED','description':'Approuver (Paramétré)'},{'key':'EXST_CANCELLED','description':'Annuler l'exemple (Paramétré)'}] fieldName="" otherFieldName="" otherValue="" otherFieldSize=0 dDFCurrent="first-in-list" ajaxEnabled=false noCurrentSelectedKey="" ajaxOptions="" frequency="" minChars="" choices="" autoSelect="" partialSearch="" partialChars="" ignoreCase="" fullSearch="" tabindex="" />

          The error is caused by the description value: ,'description':'Annuler l'exemple (Paramétré)'. If changing the "Annuler l'exemple" to "Annuler lexemple" in CommonEntityLabels.xml, the error will disappear. I tested changing to "Annuler l'exemple" and failed. "Annuler l`exemple" works.

          I guess the "Annuler l'exemple" has to be changed to other expression but I don't know how to do it.

          Show
          shi.jinghai Shi Jinghai added a comment - Hi Jacques, When locale is fr, the error message in error.log is: http-bio-8443-exec-1 MacroFormRenderer E Error rendering screen thru ftl, macro: <@renderDropDownField name="statusId" className="required" alert="false" id="EditExample_statusId" multiple="" formName="EditExample" otherFieldName="" event="" action="" size="1" firstInList="first-in-list" currentValue="EXST_DEFINED" explicitDescription="Paramétré" allowEmpty="" options= [{'key':'EXST_APPROVED','description':'Approuver (Paramétré)'},{'key':'EXST_CANCELLED','description':'Annuler l'exemple (Paramétré)'}] fieldName="" otherFieldName="" otherValue="" otherFieldSize=0 dDFCurrent="first-in-list" ajaxEnabled=false noCurrentSelectedKey="" ajaxOptions="" frequency="" minChars="" choices="" autoSelect="" partialSearch="" partialChars="" ignoreCase="" fullSearch="" tabindex="" /> The error is caused by the description value: ,'description':'Annuler l'exemple (Paramétré)'. If changing the "Annuler l'exemple" to "Annuler lexemple" in CommonEntityLabels.xml, the error will disappear. I tested changing to "Annuler l'exemple" and failed. "Annuler l`exemple" works. I guess the "Annuler l'exemple" has to be changed to other expression but I don't know how to do it.
          Hide
          shi.jinghai Shi Jinghai added a comment -

          Ha, the html magic, I mean change ' to ascii code and failed.

          Show
          shi.jinghai Shi Jinghai added a comment - Ha, the html magic, I mean change ' to ascii code and failed.
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Thanks Jinghai, I will see how to fix it

          Show
          jacques.le.roux Jacques Le Roux added a comment - Thanks Jinghai, I will see how to fix it
          Hide
          jacques.le.roux Jacques Le Roux added a comment - - edited

          To clarify the issue: when a description used in a drop-down comes from a localised label in CommonEntityLabels.xml and contains a single quote (') this single quote must be percent encoded to allow the rendering. Else it's a single quote inside 2 single quotes for the option like:

          {'key':'EXST_CANCELLED','description':'Annuler l'exemple (En projet)'}
          

          with the percent encoding there is no issue:

          {'key':'EXST_CANCELLED','description':'Annuler l%27exemple (En projet)'}
          

          By percent encoding (ie %27) the ' char (single-quote or apostrophe)

           (indeed html entity encoding (ie &#39;) did not work)
           

          I could bypass the issue due to this call to renderDropDownField macro, where having ' inside 'Annuler l'exemple (En projet)' could not work

          <@renderDropDownField [...] options=[{'key':'EXST_DEFINED','description':'Définition complète (En projet)'},{'key':'EXST_CANCELLED','description':'Annuler l%27exemple (En projet)'}] [...]  />
          

          Since there are many (200+) single quotes used in CommonErrorUiLabels.xml (not only in French) I looked for a more general option to percent encode the description when creating the options in MacroFormRenderer.renderDropDownField(). Actually there the private encode() method, which relies on the simpleEncoder or String encoder, is already used. In this case, so far and I guess ever, we only need to encode the the ' char. So It's easier to simply force it using a String.replaceAll("'", "%27"). This workd, but has an annoying side-effect: then the localised labels containing a single quote are rendered in drop-downs with "%27" instead of '. I thought I could try to change that inside renderDropDownField macro in htmlFormMacroLibrary.ftl. But I was unable to replace "%27" by ' with Freemarker by using

          item.description?replace("%27", "'")
          

          I tried many solutions using regexps rather, like

          replace("[%]27", "'", "r")
          

          none worked.

          So this would be my patch if I could replace % in Freemarker. BTW I'm not even sure it will not reintroduce the issue I'm fighting :/

          Index: framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java
          ===================================================================
          --- framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java	(revision 1692606)
          +++ framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java	(working copy)
          @@ -849,7 +849,7 @@
                       if (textSize > 0 && description.length() > textSize) {
                           description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5);
                       }
          -            options.append(encode(description, modelFormField, context));
          +            options.append(encode(description.replaceAll("'", "%27"), modelFormField, context));
          
                       if (UtilValidate.isNotEmpty(currentValueList)) {
                           options.append("'");
          Index: framework/widget/templates/htmlFormMacroLibrary.ftl
          ===================================================================
          --- framework/widget/templates/htmlFormMacroLibrary.ftl	(revision 1692606)
          +++ framework/widget/templates/htmlFormMacroLibrary.ftl	(working copy)
          @@ -231,7 +231,7 @@
             <span class="ui-widget">
               <select name="${name?default("")}<#rt/>" <@renderClass className alert /><#if id?has_content> id="${id}"</#if><#if multiple?has_content> multiple="multiple"</#if><#if otherFieldSize gt 0> onchange="process_choice(this,document.${formName}.${otherFieldName})"</#if><#if event?has_content> ${event}="${action}"</#if><#if size?has_content> size="${size}"</#if><#if tabindex?has_content> tabindex="${tabindex}"</#if><#rt/>>
                 <#if firstInList?has_content && currentValue?has_content && !multiple?has_content>
          -        <option selected="selected" value="${currentValue}">${explicitDescription}</option><#rt/>
          +        <option selected="selected" value="${currentValue}">${explicitDescription?replace("%27", "'")}</option><#rt/>
                   <option value="${currentValue}">---</option><#rt/>
                 </#if>
                 <#if allowEmpty?has_content || !options?has_content>
          @@ -239,9 +239,9 @@
                 </#if>
                 <#list options as item>
                   <#if multiple?has_content>
          -          <option<#if currentValue?has_content && item.selected?has_content> selected="${item.selected}" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected" </#if> value="${item.key}">${item.description}</option><#rt/>
          +          <option<#if currentValue?has_content && item.selected?has_content> selected="${item.selected}" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected" </#if> value="${item.key}">${item.description?replace("%27", "'")}</option><#rt/>
                   <#else>
          -          <option<#if currentValue?has_content && currentValue == item.key && dDFCurrent?has_content && "selected" == dDFCurrent> selected="selected"<#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected"</#if> value="${item.key}">${item.description}</option><#rt/>
          +          <option<#if currentValue?has_content && currentValue == item.key && dDFCurrent?has_content && "selected" == dDFCurrent> selected="selected"<#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected"</#if> value="${item.key}">${item.description?replace("[%]27", "'", "r")}</option><#rt/>
                   </#if>
                 </#list>
               </select>
          
          Show
          jacques.le.roux Jacques Le Roux added a comment - - edited To clarify the issue: when a description used in a drop-down comes from a localised label in CommonEntityLabels.xml and contains a single quote (') this single quote must be percent encoded to allow the rendering. Else it's a single quote inside 2 single quotes for the option like: {'key':'EXST_CANCELLED','description':'Annuler l'exemple (En projet)'} with the percent encoding there is no issue: {'key':'EXST_CANCELLED','description':'Annuler l%27exemple (En projet)'} By percent encoding (ie %27) the ' char (single-quote or apostrophe) (indeed html entity encoding (ie &#39;) did not work) I could bypass the issue due to this call to renderDropDownField macro, where having ' inside 'Annuler l'exemple (En projet)' could not work <@renderDropDownField [...] options=[{'key':'EXST_DEFINED','description':'Définition complète (En projet)'},{'key':'EXST_CANCELLED','description':'Annuler l%27exemple (En projet)'}] [...] /> Since there are many (200+) single quotes used in CommonErrorUiLabels.xml (not only in French) I looked for a more general option to percent encode the description when creating the options in MacroFormRenderer.renderDropDownField(). Actually there the private encode() method, which relies on the simpleEncoder or String encoder, is already used. In this case, so far and I guess ever, we only need to encode the the ' char. So It's easier to simply force it using a String.replaceAll("'", "%27"). This workd, but has an annoying side-effect: then the localised labels containing a single quote are rendered in drop-downs with "%27" instead of '. I thought I could try to change that inside renderDropDownField macro in htmlFormMacroLibrary.ftl. But I was unable to replace "%27" by ' with Freemarker by using item.description?replace( "%27" , "'" ) I tried many solutions using regexps rather, like replace( "[%]27" , "'" , "r" ) none worked. So this would be my patch if I could replace % in Freemarker. BTW I'm not even sure it will not reintroduce the issue I'm fighting :/ Index: framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java =================================================================== --- framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java (revision 1692606) +++ framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java (working copy) @@ -849,7 +849,7 @@ if (textSize > 0 && description.length() > textSize) { description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } - options.append(encode(description, modelFormField, context)); + options.append(encode(description.replaceAll( "'" , "%27" ), modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append( "'" ); Index: framework/widget/templates/htmlFormMacroLibrary.ftl =================================================================== --- framework/widget/templates/htmlFormMacroLibrary.ftl (revision 1692606) +++ framework/widget/templates/htmlFormMacroLibrary.ftl (working copy) @@ -231,7 +231,7 @@ <span class= "ui-widget" > <select name= "${name? default (" ")}<#rt/>" <@renderClass className alert /><# if id?has_content> id= "${id}" </# if ><# if multiple?has_content> multiple= "multiple" </# if ><# if otherFieldSize gt 0> onchange= "process_choice( this ,document.${formName}.${otherFieldName})" </# if ><# if event?has_content> ${event}= "${action}" </# if ><# if size?has_content> size= "${size}" </# if ><# if tabindex?has_content> tabindex= "${tabindex}" </# if ><#rt/>> <# if firstInList?has_content && currentValue?has_content && !multiple?has_content> - <option selected= "selected" value= "${currentValue}" >${explicitDescription}</option><#rt/> + <option selected= "selected" value= "${currentValue}" >${explicitDescription?replace( "%27" , "'" )}</option><#rt/> <option value= "${currentValue}" >---</option><#rt/> </# if > <# if allowEmpty?has_content || !options?has_content> @@ -239,9 +239,9 @@ </# if > <#list options as item> <# if multiple?has_content> - <option<# if currentValue?has_content && item.selected?has_content> selected= "${item.selected}" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected= "selected" </# if > value= "${item.key}" >${item.description}</option><#rt/> + <option<# if currentValue?has_content && item.selected?has_content> selected= "${item.selected}" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected= "selected" </# if > value= "${item.key}" >${item.description?replace( "%27" , "'" )}</option><#rt/> <# else > - <option<# if currentValue?has_content && currentValue == item.key && dDFCurrent?has_content && "selected" == dDFCurrent> selected= "selected" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected= "selected" </# if > value= "${item.key}" >${item.description}</option><#rt/> + <option<# if currentValue?has_content && currentValue == item.key && dDFCurrent?has_content && "selected" == dDFCurrent> selected= "selected" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected= "selected" </# if > value= "${item.key}" >${item.description?replace( "[%]27" , "'" , "r" )}</option><#rt/> </# if > </#list> </select>
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          If nobody knows how to replace a % with Freemarker replace(), then another pragmatic solution is to use ’ instead of ' (see https://en.wikipedia.org/wiki/Apostrophe). We could also use a Java call inside /htmlFormMacroLibrary.ftl

          Show
          jacques.le.roux Jacques Le Roux added a comment - If nobody knows how to replace a % with Freemarker replace(), then another pragmatic solution is to use ’ instead of ' (see https://en.wikipedia.org/wiki/Apostrophe ). We could also use a Java call inside /htmlFormMacroLibrary.ftl
          Hide
          gareth.carter Gareth Carter added a comment -

          Seems to me like you have to escape special chars. See http://freemarker.org/docs/dgui_template_exp.html - escape sequences. Apostrophe is one of those special chars

          Show
          gareth.carter Gareth Carter added a comment - Seems to me like you have to escape special chars. See http://freemarker.org/docs/dgui_template_exp.html - escape sequences. Apostrophe is one of those special chars
          Hide
          jacques.le.roux Jacques Le Roux added a comment - - edited

          Thanks Gareth, much simpler indeed, though to escape the quote you have to put 5(five!) \ before, really not obvious, also does not work in Eclipse Debugger. I still wonder how to replace a % but that's another issue Fixed at revision: 1693242

          Show
          jacques.le.roux Jacques Le Roux added a comment - - edited Thanks Gareth, much simpler indeed, though to escape the quote you have to put 5(five!) \ before, really not obvious, also does not work in Eclipse Debugger. I still wonder how to replace a % but that's another issue Fixed at revision: 1693242
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Mmm, of course still an issue in normal (not PDF) mode, I'll check that...later...

          Show
          jacques.le.roux Jacques Le Roux added a comment - Mmm, of course still an issue in normal (not PDF) mode, I'll check that...later...
          Hide
          jacques.le.roux Jacques Le Roux added a comment - - edited

          I thought I had just to replace \' by ', but I got fooled, because \' are already transformed in Unicode characters

          &#x5c;&#x27;
          

          at this stage. So at revision 1693258
          I replaced

          "&#x5c;&#x27;" by "&#x27;"
          
          Show
          jacques.le.roux Jacques Le Roux added a comment - - edited I thought I had just to replace \' by ', but I got fooled, because \' are already transformed in Unicode characters &#x5c;&#x27; at this stage. So at revision 1693258 I replaced "&#x5c;&#x27;" by "&#x27;"
          Hide
          gareth.carter Gareth Carter added a comment -

          MacroFormRenderer is creating adhoc freemarker scripts and therefore should escape all special characters from all sources. If percent/entity encoding is happening prior to generating the freemarker then these encoded values need to be escaped too.

          Eg ' should be \a#x27;

          Not exactly sure why you have to replace %27, you should only need to percent encode url parameters, the description field above (from the patch) should contain a ' apostrophe not %27.

          Show
          gareth.carter Gareth Carter added a comment - MacroFormRenderer is creating adhoc freemarker scripts and therefore should escape all special characters from all sources. If percent/entity encoding is happening prior to generating the freemarker then these encoded values need to be escaped too. Eg ' should be \a#x27; Not exactly sure why you have to replace %27, you should only need to percent encode url parameters, the description field above (from the patch) should contain a ' apostrophe not %27.
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          I don't replace %27, I only replace the \ used to escape the quotes used inside labels in CommonEntityLabels.xm.

          Show
          jacques.le.roux Jacques Le Roux added a comment - I don't replace %27, I only replace the \ used to escape the quotes used inside labels in CommonEntityLabels.xm.

            People

            • Assignee:
              shi.jinghai Shi Jinghai
              Reporter:
              SachinManjule Sachin Manjule
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development