I'm using the following: https://www.novell.com/documentation/developer/jldap/jldapenu/api/com/novell/ldap/util/DN.html in my application.
For the creation of the DN object, I need to put dnString, that must adhere to the syntax described in RFC 2253.
My DN contains: "\" and "," characters (also "\," both right after each other).
I could not find any site that explains exactly how to get a valid DN for RFC 2253. I found:
https://ldapwiki.com/wiki/RFC%202253
https://www.rfc-editor.org/rfc/pdfrfc/rfc2253.txt.pdf
Both mention that "," and "\" are special characters, but none states how to escape it correctly.
How can I get the valid DN with these values?
Page 4 of RFC 2253:
If a character to be escaped is one of the list shown above, then it is prefixed by a backslash (’\’ ASCII 92).
So an escaped comma should be \, and an escaped backslash should be \\.
A comma is a separator in a DN. For example:
cn=admin,ou=marketing,o=corporation
so it needs to be escaped only when it is not used as a separator, like this:
cn=Smith\, John,ou=marketing,o=corporation
Active Directory will escape it for you if you create an object with a CN that has a comma.
The backslash is a special character because it's used to escape other characters. So if you are not using it for that purpose, it needs to be escaped using itself:
cn=North\\South America,ou=marketing,o=corporation
Although in that example I'd use a forward slash ("North/South America"), which brings up another point (unrelated to your immediate problem, but worth mentioning): the forward slash is not a special character in DNs, but they are in LDAP paths. So if you had a DN like this:
cn=North/South America,ou=marketing,o=corporation
Then if you need to use that in an LDAP path, you can't just drop that in:
LDAP://cn=North/South America,ou=marketing,o=corporation
because / is a separator character, so it would think that the DN is just cn=North. In those cases, you need to escape that with a backslash too:
LDAP://cn=North\/South America,ou=marketing,o=corporation
But only when you use it in an LDAP path.
Related
$.validator.addMethod('AZ09_', function (value) {
return /^[a-zA-Z0-9.-_]+$/.test(value);
}, 'Only letters, numbers, and _-. are allowed');
When I use somehting like test-123 it still triggers as if the hyphen is invalid. I tried \- and --
Escaping using \- should be fine, but you can also try putting it at the beginning or the end of the character class. This should work for you:
/^[a-zA-Z0-9._-]+$/
Escaping the hyphen using \- is the correct way.
I have verified that the expression /^[a-zA-Z0-9.\-_]+$/ does allow hyphens. You can also use the \w class to shorten it to /^[\w.\-]+$/.
(Putting the hyphen last in the expression actually causes it to not require escaping, as it then can't be part of a range, however you might still want to get into the habit of always escaping it.)
The \- maybe wasn't working because you passed the whole stuff from the server with a string. If that's the case, you should at first escape the \ so the server side program can handle it too.
In a server side string: \\-
On the client side: \-
In regex (covers): -
Or you can simply put at the and of the [] brackets.
Generally with hyphen (-) character in regex, its important to note the difference between escaping (\-) and not escaping (-) the hyphen because hyphen apart from being a character themselves are parsed to specify range in regex.
In the first case, with escaped hyphen (\-), regex will only match the hyphen as in example /^[+\-.]+$/
In the second case, not escaping for example /^[+-.]+$/ here since the hyphen is between plus and dot so it will match all characters with ASCII values between 43 (for plus) and 46 (for dot), so will include comma (ASCII value of 44) as a side-effect.
\- should work to escape the - in the character range. Can you quote what you tested when it didn't seem to? Because it seems to work: http://jsbin.com/odita3
A more generic way of matching hyphens is by using the character class for hyphens and dashes ("\p{Pd}" without quotes). If you are dealing with text from various cultures and sources, you might find that there are more types of hyphens out there, not just one character. You can add that inside the [] expression
When running sqlpackage.exe for deployments, do string variables require quotes around the word? It seems to be running successfully both ways. What is the correct syntax?
Two options shown here:
/v:CompanyName=ABCD
/v:CompanyName="ABCD"
Resource: https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage?view=sql-server-ver15
#Jeroen Mostert is right. It's more related to the command line not only the SqlPackage.
If the string variable contains spaces equality signs, slashes, or anything else that would interfere with option syntax, the value must be surrounded in "quotes".
Here is the example blog: https://www.addictivetips.com/windows-tips/enter-file-or-folder-paths-with-spaces-in-command-prompt-on-windows-10/
If all of the following conditions are met, then quote characters on the command line are preserved:
No /S switch (Strip quotes)
Exactly two quote characters
No special characters between the two quote characters, where special is one of: & < >( ) # ^ |
There are one or more whitespace characters between the the two quote characters
The string between the two quote characters is the name of an executable file.
Ref: https://ss64.com/nt/syntax-cmd.html
HTH.
Im using JREPL.BAT to find and replace specific instances and my regex I have works for find and replace in VSC code and also in the couple regex editors I've used.
CALL ./framework/config/JREPL.BAT "(Error)+\(([^()]*|\(([^()]*|\([^()]*\))*\))*\)" "Error(\"\")" /f ./dist/index.html /o
so what I'm expecting is it to find any case of
Error("")
or
Error( skjdksjdskd() + "" + )
etc
Find and replace works perfectly but jrepl takes
Error( skjdksjdskd() + "" + )
and changes it to
Error()( skjdksjdskd() + "" + )
does anyone know with more JREPL experience know why its ignoring the quotes and also not replacing the () area?
JREPL is hybrid JScript/batch that uses CSCRIPT - the Windows script host.
CSCRIPT has an inherent limitation that prevents double quote literals from being passed as parameters - there is no CSCRIPT escape sequence that includes a " literal.
To include a " literal in your query string, you can use \x22 instead. All of the standard JScript escape sequences can be used in the query string. By default, escape sequences are not recognized in the replace string.
But you want a quote literal in your replace string. This requires the /XSEQ option so you can use the JREPL extended escape sequence of \q. A significant advantage of this option is you can also use the extended escape sequences in the replace string. You could also use \x22 for both the search and replace strings if you prefer, but I find \q much easier to remember.
You have one other potential problem - the CALL command doubles all quoted carets, so [^()] (any character other than ( or )) becomes [^^()] (any character other than ^, ( or )). This is definitely not what you want. That is the reason I added the \c = ^ extended escape sequence.
So I believe the following will give your expected result:
CALL .\framework\config\JREPL.BAT "(Error)+\(([\c()]*|\(([\c()]*|\([\c()]*\))*\))*\)" "Error(\q\q)" /xseq /f .\dist\index.html /o -
FYI - The effect of the ^ beginning of string anchor is not harmed by caret doubling - you don't need the \c escape sequence for the beginning of string anchor because "^MatchStringBeginning" and "^^MatchStringBeginning" yield identical regex results.
You can get more information about the extended escape sequences by issuing jrepl /?/xseq, or jrepl /??/xseq for paged help.
>jrepl /?/xseq
/XSEQ - Enables extended escape sequences for both Search strings and
Replacement strings, with support for the following sequences:
\\ - Backslash
\b - Backspace
\c - Caret (^)
\f - Formfeed
\n - Newline
\q - Quote (")
\r - Carriage Return
\t - Horizontal Tab
\v - Vertical Tab
\xnn - Extended ASCII byte code expressed as 2 hex digits nn.
The code is mapped to the correct Unicode code point,
depending on the chosen character set. If used within
a Find string, then the input character set is used. If
within a Replacement string, then the output character
set is used. If the selected character set is invalid or
not a single byte character set, then \xnn is treated as
a Unicode code point. Note that extended ASCII character
class ranges like [\xnn-\xnn] should not be used because
the intended range likely does not map to a contiguous
set of Unicode code points - use [\x{nn-mm}] instead.
\x{nn-mm} - A range of extended ASCII byte codes for use within
a regular expression character class expression. The
The min value nn and max value mm are expressed as hex
digits. The range is automatically expanded into the
full set of mapped Unicode code points. The character
set mapping rules are the same as for \xnn.
\x{nn,CharSet} - Same as \xnn, except explicitly uses CharSet
character set mapping.
\x{nn-mm,CharSet} - Same as \x{nn-mm}, except explicitly uses
CharSet character set mapping.
\unnnn - Unicode code point expressed as 4 hex digits nnnn.
\u{N} - Any Unicode code point where N is 1 to 6 hex digits
JREPL automatically creates an XBYTES.DAT file containing all 256
possible byte codes. The XBYTES.DAT file is preferentially created
in "%ALLUSERSPROFILE%\JREPL\" if at all possible. Otherwise the
file is created in "%TEMP%\JREPL\" instead. JREPL uses the file
to establish the correct \xnn byte code mapping for each character
set. Once created, successive runs reuse the same XBYTES.DAT file.
If the file gets corrupted, then use the /XBYTES option to force
creation of a new XBYTES.DAT file. If JREPL cannot create the file
for any reason, then JREPL silently defaults to using pre v7.4
behavior where /XSEQ \xnn is interpreted as Windows-1252. Creation
of XBYTES.DAT requires either CERTUTIL.EXE or ADO. It is possible
that both may be missing from an XP machine.
Without the /XSEQ option, only standard JSCRIPT escape sequences
\\, \b, \f, \n, \r, \t, \v, \xnn, \unnnn are available for the
search strings. And the \xnn sequence represents a unicode
code point, not extended ASCII.
Extended escape sequences are supported even when the /L option
is used. Both Search and Replace support all of the extended
escape sequences if both the /XSEQ and /L options are combined.
Extended escape sequences are not applied to JScript code when
using any of the /Jxxx options. Use the decode() function if
extended escape sequences are needed within the code.
Final Answer for this is to escape the quotes and backslashes as \" AND \\ when using CALL in Webpack-shell-plugin.
'call "./framework/config/JREPL.BAT" \"(Error)\\(([\\c()]*|\\(([\\c()]*|\\([\\c()]*\\))*\\))*\\)\" \"Error(\\q\\q)\" /xseq /f ./dist/index.html /o ./dist/indexFinal.html'
If I send a natural-language query to Retrieve and Rank (Solr), it will return an error if the query contains a colon. It seems to be attempting to interpret the word just prior to the colon as a field name.
Is there any way to prevent this, and are there other characters like this to which I should be aware?
The list of characters you'll need to handle is at http://www.ibm.com/watson/developercloud/doc/retrieve-rank/plugin_query_syntax.shtml - it's at the bottom of the page under the heading "Reserved characters". (This also includes how to handle them)
These include:
Colon (:)
Escape a colon in a query with a backslash.
Double quotation marks (")
Escape double quotation marks in a query with a backslash in field queries.
Backslash (\) Escape character
Escape a backslash in a query with another backslash.
You'll have to escape the colon - if your Solr library isn't doing this for you automagically. Escaping uses \ as in most other cases, so foo\:bar should work. Another option might be to wrap the value in quotes (field:"foo:bar").
Why aren't \a (beep),\v(vertical tab) not working in my program even though they are standard according to the links below?And why is a single quotation mark working even without using it as \'? And finally,is \? an escape character at all as that Microsoft site says,because I use the ? symbol inside a printf() format string without \ and it works fine.
To put it clearly:
Why are \a and \v not working?
Why single quote works without the \ even though \' is an escape sequence?
Is \? an escape sequence?(The link says so but ? works without the \)
http://msdn.microsoft.com/en-us/library/h21280bw(v=vs.80).aspx
http://en.wikipedia.org/wiki/Escape_sequences_in_C
Why are \a and \v not working?
Because the console you’re using doesn’t support them. The compiler does, and produces the correct character code in the output, but the terminal emulator ignores them.
Why single quote works without the \ even though \' is an escape sequence?
Because it’s unnecessary to escape it in strings, you only need to escape it in a char literal. Same for \" for string literal:
"'" vs. '\''
'"' vs. "\""
Is \? an escape sequence? (The link says so but ? works without the \)
The link actually says something different:
Note that … \? specifies a literal question mark in cases where the character sequence would be misinterpreted as a trigraph
It’s only there to avoid ambiguity in cases where the following characters would form a valid trigraph, such as ??= (which is the trigraph for #). If you want to use this sequence in a string, you need to escape the first (or second) ?.
Some of the escape sequences are device specific. So they don't produce the desired on effect on every device. For example, the vertical tab (\v) and form feed (\f) escape sequences do not affect screen output. But they do perform the appropriate printer operations.