0

how can I escape " in NVelocity ?

e.g. test.message = "136# 1/4" Test Test Test"

if I do <input type="text" id="Test.Description" value="$test.message"/>

it displays : 136# 1/4

if I do <input type="text" id="Test.Description" value=$test.message/>

it displays : 136

if I do <input type="text" id="Test.Description" value='$test.message'/>

it displays : 136# 1/4" Test Test Test but it escapes '

how can I display 136# 1/4" Test Test Test without escaping anything ?

MJB
  • 7,639
  • 2
  • 31
  • 41
devmet
  • 3
  • 3

1 Answers1

1

nVelocity, at this time, has no built-in facility for HTML-encoding it's variables (there has been some talk about adding it in a future version)

In the meantime, in your controller, you'll just need to do:

test.message = HttpUtility.HtmlEncode(test.message);

or

test.message = test.message.Replace("\"", "&quot;");
James Curran
  • 101,701
  • 37
  • 181
  • 258