I found a solution, it seemed that I made a stupid mistake somewhere. But the 
following solution will work to preserve the original text in the edit field.

Add the following to your parameter
    <param name="myparameter" type="text" area="true" size="40x80" 
label="sample parameter">
      <sanitizer>
        <valid initial="default">
          <add preset="string.printable"/>
      <remove value="&quot;"/>
      <remove value="\"/>
      <remove value="&#xA;"/>
      <remove value="&#xD;"/>
      <remove value="&amp;"/>
        </valid>
    <mapping initial="none">
          <add source="\" target="\\"/>
          <add source="&quot;" target="\&quot;"/>
      <add source="&amp;" target="&amp;&amp;"/>
      <add source="&#xA;" target="&amp;n"/>
      <add source="&#xD;" target="&amp;r"/>
        </mapping>
      </sanitizer>
    </param>
I make use of to escape characters I use \ for \ and " and use & for the 
newline and carage return, because otherwise \n will reformatted to \\n once i 
get it inside ruby.

Then I use the following code in ruby to decode it again
def unescape(val)
  res = ""
  escape = false
  val.each_char do |char|
    if escape
      escape = false
      case char
      when '&'
        res += '&'
      when '\\'
        res += '\\'
      when 'n'
        res += "\n"
      when '\"'
        res += '\"'
      end
    else
      if char == '\\' || char == '&'
        escape = true
      else
        res += char
      end
    end
  end
  return res
end

If you want to preserve tabs you will have to add them, but example should be 
clear on how to do that.




___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Reply via email to