Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding Symbol Constants #368

Closed
RehanSaeed opened this issue Feb 24, 2017 · 4 comments
Closed

Encoding Symbol Constants #368

RehanSaeed opened this issue Feb 24, 2017 · 4 comments

Comments

@RehanSaeed
Copy link

If I have a constant symbol that determines the assembly product in a .csproj and I enter an &, the ampersand needs to be XML encoded.

@mlorbetske
Copy link
Contributor

How do you think would be the best way to do this? Automatic escaping that the engine just does transparently, with a special directive that indicates that replacements in a particular region should be escaped in a certain way (in the content files), an alternate value form (like how name changes behavior between file name, namespace and class) or a special indication in the config?

@RehanSaeed
Copy link
Author

RehanSaeed commented Feb 26, 2017

Not entirely sure. A default of being encoded by default might be good but with a way of turning that off and/or configuring it.

@mlorbetske
Copy link
Contributor

Assuming that the value that needs to be encoded in the XML is encoded in the XML already, you can use name forms for this.

Ex.

{
  "symbols": {
    "x": {
      "type": "parameter",
      "dataType": "string",
      "replaces": "Test\"Value",
      "forms": [ "encode" ]
   },
  "forms": {
    "encode": {
      "identifier": "xmlEncode"
    }
  }
}

This will replace the literal Test"Value with the literal the user supplies and it will also replace the XML encoded form (Test"Value) with the XML encoded form of the user's value.

@seancpeters
Copy link
Contributor

Note: The syntax for defining value forms in template.json has changed since this post. See #1524 for an updated example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants