CouchDB not allowing '+' in database name - couchdb

CouchDB v3.2.1 on Ubuntu 20.04.4
curl -X PUT https://localhost:6984/test+database --cookie 'AuthSession=<session cookie>'
gives the error:
{"error":"illegal_database_name","reason":"Name: 'test database'. Only lowercase characters (a-z), digits (0-9), and any of the characters _, $, (, ), +, -, and / are allowed. Must begin with a letter."}
Trying to create the database using Fauxton gives the same error.
Notice that in the error message it is changing '+' to ' '.
I've seen other questions here regarding not being able to delete a database with a '+' in the name as well. Is this a recent bug in couchdb where it no longer allows '+'?

Indeed a + is a legal character for a database name according to PUT /{db}:
Creates a new database. The database name {db} must be composed by
following next rules:
Name must begin with a lowercase letter (a-z)
Lowercase characters (a-z)
Digits (0-9)
Any of the characters _, $, (, ), +, -, and /.
SO to the problem at hand - simply percent encode that +
curl -X PUT https://localhost:6984/test%2Bdatabase --cookie 'AuthSession=<session cookie>'
This is a curl thing, not a couchdb thing.

Related

Adding new line before string matching regex in linux (Jenkins)

Hi I'm trying to do some CSV manipulation before processing. Now I'm strungling with following scenario.
Input file (no line breaks):
timeStamp,elapsed,label,responseCode,responseMessage,threadName,success,failureMessage,bytes,sentBytes,Latency,IdleTime 1611013105559,492,REST API,200,,REST API 1-1,true,,1221,32292,492,0 1611013107054,575,DB check,200,OK,REST API 1-1,true,,177,0,575,0 1611013251449,231,DB check,null 0,"java.sql.SQLException: Cannot create PoolableConnectionFactory (ORA-28040: No matching authentication protocol )",REST API 1-1,false,Row not inserted properly.,89,0,0,0
Desired output (new line before the timestamp):
timeStamp,elapsed,label,responseCode,responseMessage,threadName,success,failureMessage,bytes,sentBytes,Latency,IdleTime
1611013105559,492,REST API,200,,REST API 1-1,true,,1221,32292,492,0
1611013107054,575,DB check,200,OK,REST API 1-1,true,,177,0,575,0
1611013251449,231,DB check,null 0,"java.sql.SQLException: Cannot create PoolableConnectionFactory (ORA-28040: No matching authentication protocol )",REST API 1-1,false,Row not inserted properly.,89,0,0,0
Actual output:
timeStamp,elapsed,label,responseCode,responseMessage,threadName,success,failureMessage,bytes,sentBytes,Latency,IdleTime
[0-9]{13},492,REST API,200,,REST API 1-1,true,,1221,32292,492,0
[0-9]{13},575,DB check,200,OK,REST API 1-1,true,,177,0,575,0
[0-9]{13},231,DB check,null 0,"java.sql.SQLException: Cannot create PoolableConnectionFactory (ORA-28040: No matching authentication protocol )",REST API 1-1,false,Row not inserted properly.,89,0,0,0
Using this command:
awk -v patt=[0-9]{13} '$0 ~ patt {gsub(patt, "\n"patt)}1' < input.jtl > output.jtl
Anyone can help please?
Regards Jan
With awk could you please try following, written and tested with shown samples.
awk '{gsub(/[0-9]{13},[0-9]{3}/,ORS"&")} 1' Input_file > output.jtl
Explanation: Simply globally substitutinggsub matched regex [0-9]{13},[0-9]{3} value with ORS(new line) and with the matched value itself. 1 will print the edited/non-edited current line.
If you want to use backreference use gensub. In your case we might do
awk '{print gensub(/([0-9]{13})/, "\n\\1", "g")}' input.jtl
Note that I enclosed [0-9]{13} in () thus making it first (and only) group which I then reference as \\1, g mean global replacement (all occurences). gensub does return new string rather than changing, so I print it. If you want to know more about gensub then read String Functions docs.
You can use a GNU sed like
sed -E 's/\<[0-9]{13}\>/\n&/g' input.jtl > output.jtl
Details:
-E - enables POSIX ERE syntax (less escaping required)
\<[0-9]{13}\> - matches a leading word boundary, thirteen digits and a trailing word boundary
\n& - replaces the match with a newline and the match itself
g - all occurrences on a line.

How do you escape round brackets in passwords for bitbucket-api in node.js

I am trying to access a particular repository on BitBucket using bitbucket-api in node.js and my password contains funny characters (round brackets and spaces). It doesn't throw any useful errors or let me get the data.
I happen to like my password so I don't want to change it. I know that removing the round brackets and spaces from the password fixes the issue.
What can I do?
After plenty of searching and stepping into the implementation for curl-transport.js, I have found a way to work around this issue. It relies on understanding of what curl-transport passes to require('child_process').exec.
Essentially the mechanism works by starting a new process for CURL and passing in command line arguments. By having round brackets, it confuses CURL and by having spaces it confuses the command line argument parsing. So to work around it, simply add a double quote as the first character of the username and an ending double quote as the last character of the password; so when the two strings get concatenated (ie: username+":"+password) then the final string will be "USERNAME:PASSWORD" which get's passed as one argument to the process.
My node code looks like this:
var bitbucket = require('bitbucket-api');
var credentials = { username: '"USERNAME', password: 'PASSWORD With Spaces and ()s"' };
var client = bitbucket.createClient(credentials);
var repository = client.getRepository({ slug: 'repoName', owner: 'USERNAME' }, function (err, repo) {
//Code to access the repo object.
console.log(repo);
});
Notice how username has an additional double quote at the beginning of the value (this is the hack). I have added spaces and emphasised it below because it's not obvious::
username: ' " USERNAME'
Notice how password has an additional double quote at the end of the value (this is the hack). I have added spaces and emphasised it below because it's not obvious:
password: 'PASSWORD With Spaces and ()s " '
The call will then succeed and you will get back the details for your repository.
BTW, this fix worked for me in V0.0.6 of bitbucket-api on Windows 8.
A helpful note:
On windows, please remember to put the following into your path so that it can find CURL. You can do this through [Win8: Windows-X]->System->Advanced System Settings->Advanced->System Variables->Path->Edit...
Make sure git's binaries are in the path for CURL:
C:\Program Files (x86)\Git\bin
Also, if you are trying to get it to work on heroku then you might need to work around pathing issues by re-installing the Heroku toolbelt under C:\Heroku (see other posts for why) and adding the following to the path:
C:\Heroku\ruby-1.9.2\bin;C:\Heroku\bin;C:\Program Files (x86)\Git\bin

How to insert "/" in the name of the content type in sharepoint

I want to create one content type with name "General Information/General Services". But when I am trying to create it is throwing an error that special characters (in my case it is "/") are not allowed. For this I tried to insert with the ANSI character of slash. But & symbol is not allowing to enter. Any suggestion for this problem.
I added that screen shot for reference.
The Content Type Name value can be a reference to a resource in the format $Resources:String.
For more information, see Localizing SharePoint Solutions. The name itself cannot be longer than 128 characters and cannot contain the characters \ / : * ? " # % < > { } | ~ &, two consecutive periods (..), or special characters, such as a tab.
Please see this link
http://msdn.microsoft.com/en-us/library/ms460224(v=office.14).aspx

How to disable / enable futon in couchdb?

I have a couchdb, running in a non-standard port, which is giving me the following:
http://localhost:59876/_utils
{"error":"illegal_database_name","reason":"Only lowercase characters (a-z), digits (0-9), and any of the characters _, $, (, ), +, -, and / are allowed. Must begin with a letter."}
Which shows me that futon is disabled. Is there any setting in the config file which would allow me to enable (and disable) futon?
That is not normal. I wonder if you have any config file issue. There should be a configuration entry like this.
[httpd_global_handlers]
_utils = {couch_httpd_misc_handlers, handle_utils_dir_req, "/usr/local/share/couchdb/www"}
That is what tells CouchDB that _utils is an ok query and it sill serve Futon.

Regular Expression validating hyperlink for export to Excel

I have a web application that takes input from a user, usually in the form of a filepath, hyperlink, or fileshare, but not always. A user may enter "\my.fileshare.com", "http://www.msdn.com", or "In my file cabinent". These inputs are exported to a Excel file. However, if the input is in the form of "\look on my desk" or "http://here it is" (notice the spaces), after the file is exported, and opened, Excel raises the ever so descriptive error message of, and I quote, "Error".
I'm adding to the existing code a regular expression validator to the textbox the user enters and edits these locations in. Because there are a large number of existing entries, the validator needs to be specific as possible, and only toss out the inputs that cause the Excel export to break. For example "\Will Work" will work, as will "Will Work", and "\This\will also work". I need a regular expression that if the string starts with \, http://, https://, ftp://, ftps://, the server or fileshare name does not have a space in it, and if it does not start with the \, http://, https://, ftp://, ftps://, its fine regardless.
I've been able to write the first part
^(\\)[^ \]+(\.)$|^(((ht|f)tp(s)?)://)[^ /]+(/.)$
but I can't figure out how to say ignore everything if it does not start with \, http://, https://, ftp://, ftps://.
^(?:(?:\\|(?:ht|f)tps?://)\S+|(?!\\|(?:ht|f)tps?://).*)$
Explained:
^ # start-of string
(?: # begin non-capturing group
(?:\\|(?:ht|f)tps?://)\S+ # "\, http, ftp" followed by non-spaces
| # or
(?!\\|(?:ht|f)tps?://).* # NOT "\, http, ftp" followed by anything
) # end non-capturing group
$ # end-of-string
This is pure, unescaped regex. Add character escaping according to the rules of your environment.
EDIT: Ooops premature.
This expression still doesn't allow "http://www.google.com/hello world" :/
EDIT FOR A THIRD TIME
Here we go!
^(?:(?:\\|(?:ht|f)tps?://)[^ /\]+([/\].)?|(?!\\|(?:ht|f)tps?://).)$

Resources