For WebSphere Liberty Profile, backslash character inside bootstrap.properties file - websphere-liberty

I am having issue with the '\' (backslash) character inside bootstrap.properties file.
I first define a variable within bootstrap.properties file:
var1=AB\AC
Then, I define a jndiEntry inside server.xml file:
<jndiEntry value="${var1}" jndiName="jndi/var1" id="var1">
When I look up jndi entry in my code, the '\' is lost. If I use double backslash, i.e., '\\', then what I get is a forward slash, i.e., 'AB/AC'.
How can I input '\' character?

Liberty will perform path normalization on all variables unless the attribute is defined as a password type. The only way to get around this currently would be to include the backslash character in server.xml rather than bootstrap.properties.
For example, in server.xml:
<jndiEntry value="${var1}\${var2}" jndiName="jndi/var1" id="var1">
bootstrap.properties:
var1=AB
var2=BC

According to Liberty documentation, path normalization is performed on all variables located in bootstrap.properties file
by replacing repeated forward and backward slashes with a single
forward slash, unless the value starts with double forward or backward
slashes, which remain unchanged.
However, according to their "Best practices" section:
If you need to set the value of a variable to contain repeated forward
slashes, as are sometimes used for JDBC driver connection URLs, break
the value into two parts at the double slashes. By placing the double
forward slashes as the initial characters, normalization is avoided.
For example, to store the value "jdbc:db2://host_name.com", use two
variables:
URL_PART_1="jdbc:db2:"
URL_PART_2="//host_name.com"

Related

Routing in dotnet core 3

I am useing [Route("/{controller}/{action}/{name}")]
I have an action that takes the name of an item as an argument, and the name can have spaces in it, so when it shows in the URL they replace spaces with %20 how can I change the spaces to a dash (-) without messing the code.
ASCII Encoding Reference is a default role that you can't change it . It just replaces the original Character with another Character and does not change its value.

Space in parameters for Azure SQL Data Warehouse connection string

I am upgrading my JDBC connection string right now on my Azure SQL Data Warehouse to the new specifications, specifically, adding the following to it: Application Name=MyApp.
Here's my issue. I connect to my server using the following string:
jdbc:sqlserver://localhost:1234;database=mydb;encrypt=true;trustServerCertificate=true;
If I add the application name to my string, it will become the following:
jdbc:sqlserver://localhost:1234;database=mydb;encrypt=true;trustServerCertificate=true;Application Name=MyApp
See the space between Application and Name?
My question is - is this right? And do I need to encode that space to something like %20?
Nowhere in the Microsoft docs do they mention this necessity if the connection string is a URL..
EDIT 1: I found something sort of related to the JDBC connection strings, but it doesn't specify any params that may contain spaces: https://azure.microsoft.com/en-us/documentation/articles/sql-data-warehouse-connect-overview/
EDIT 2: Found this here
Escaping Values in the Connection URL
You might have to escape certain parts of the connection URL values because of the inclusion of special characters such as spaces, semicolons, and quotation marks. The JDBC driver supports escaping these characters if they are enclosed in braces. For example, {;} escapes a semicolon.
Escaped values can contain special characters (especially '=', ';', '[]', and space) but cannot contain braces. Values that must be escaped and contain braces should be added to a properties collection.
You should not have to add any escape characters for the Application Name property. The comments about escaping apply to the URL component of your connection string and not the whole connection string.
I believe, though, that you should be using ApplicationName as the property value anyways.

Escape characters in teradata jdbc connection string

I have a teradata database name that contains a dash character -.
Searched the web but in vain. Does somebody know how can you escape the special characters in jdbc connection string? The string looks as follows:
jdbc:teradata://HostName/DATABASE=Database-Name
When I create a connection with this url I get syntax error. Also tried to put database parameter in single or double quotes, and to surround the special charachers with { }.
Thanks for help!
Finally found the answer here: https://jira.talendforge.org/browse/TDI-18863. The correct way is to enclose both parameter name and value in single quotes:
jdbc:teradata://HostName/'DATABASE=Database-Name'
Update: No, this does not work, see comment below.
Answering my own question:
My problem was that I didn't realise that my database name had some trailing whitespaces in the end.
TeraDriver uses single quotes to escape spaces and commas. This means that the database name should be in single quotes. If there are no single quotes, spaces and commas are considered to be the end of parameter value. If there are single quotes in database name, they should be presented as two single quote characters.
'Database-Name '
Whatever is within single quotes will be used with sql query: "database Database-Name". To escape '-' we need double quotes. So both single and double quotes in correct order should be used:
"jdbc:teradata://HostName/DATABASE='\"Database-Name\"'"
Have you tried a \ character which is supposed to be an escape character in Java?
jdbc:teradata://HostName/DATABASE=Database\-Name

Bash Variable escape character

I'm attempting to generate a url using a bunch of different variables however when I follow a variable with an underscore the variable after the underscore does not show up. However, if I put a space before the underscore then there is a space in the generated URL. So my question is, is there an escape character for doing the sort of thing I have described?
Also code:
URL="$baseURL$BUILD/TorBrowserBundle-$BUILD-$OS$BIT _$LANG.zip"
The issue occurs in between $BIT and $LANG.
you can use ${}
so something like
URL="${baseURL}${BUILD}/TorBrowserBundle-${BUILD}-${OS}${BIT}_${LANG}.zip"

Allowed characters in map key identifier in YAML?

Which characters are and are not allowed in a key (i.e. example in example: "Value") in YAML?
According to the YAML 1.2 specification simply advises using printable characters with explicit control characters being excluded (see here):
In constructing key names, characters the YAML spec. uses to denote syntax or special meaning need to be avoided (e.g. # denotes comment, > denotes folding, - denotes list, etc.).
Essentially, you are left to the relative coding conventions (restrictions) by whatever code (parser/tool implementation) that needs to consume your YAML document. The more you stick with alphanumerics the better; it has simply been our experience that the underscore has worked with most tooling we have encountered.
It has been a shared practice with others we work with to convert the period character . to an underscore character _ when mapping namespace syntax that uses periods to YAML. Some people have similarly used hyphens successfully, but we have seen it misconstrued in some implementations.
Any character (if properly quoted by either single quotes 'example' or double quotes "example"). Please be aware that the key does not have to be a scalar ('example'). It can be a list or a map.

Resources