How to disable / enable futon in couchdb? - 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.

Related

CouchDB not allowing '+' in database name

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.

In Freeplane Scripts, how to deal with special characters in node links to operating system commands

I'm trying to create a link to a shell script in a Node in Freeplane.
When I monitor the text in the node node.link.text I get execute_:script.sh%20/home/dir/file.ext
Ok, It works, but when my path has special characters link spaces or ( ), it isn't able to open. I already tried to use URLEncoder from java.net:
filePath='/home/user/Books/Author Name/File (231)/Book - Author.pdf'
urlEncoder = new URLEncoder()
def urlEncode(String s) {
urlEncoder.encode(s).replace("+", "%20");
}
fileLink = 'execute:_docreader.sh%20-p%20' + page + '%20' + urlEncode(filePath)
createdNode.link.setText(fileLink)
But I couldn't execute any command with files as arguments whose path have special characters. I even tried to put ' or " in the path manually but it didn't work too.
If filePath are without special characters, like /home/user/Books/AuthorName/file.pdf it works fine.
I look into Freeplane wiki and Freeplane API, looked into the examples but havent found any clue about that.

How to make apache treat query string as file name?

I mirrored a site to local server with wget and the file names locally look like this:
comments
comments?id=123
Locally these are static files that show unique content.
But when I access second file in browser it keeps showing content from file comments and appends the query string to it ?id=123 so it is not showing content from file comments?id=123
It loads the correct file if I manually encode the ? TO %3F in browser window and I type:
comments%3Fid=123
Is there a way to fix this ? Maybe make apache stop treating ? as query separator and treat it as file name character ? Or make an URL rewrite and change ? into %3F ?
Edit: Indeed too many problems caused by ? in file name and requests. I ended up using the wget option --restrict-file-names=windows that would convert ? into an # when saving file name.
The short answer is "don't do that."
The longer answer is that ? is a reserved character in URLs, using it as a part of a filename is going to cause problems forever, and the recommended solution is to pick a different character to use in those filenames. There are many to choose from - just avoid ? & # and # and you'll probably be fine.
If you insist on keeping the file name (or if you don't have an option) try:
RewriteCond %{QUERY_STRING} (.*)
RewriteRule (.*) $1%%3F%1 [NE]
However, this is going to fire any time you have a query string, which is likely not what you want.

Apache userdir + suEXEC + fcgid doesn't recognise dot separated useraccounts

I've setup Apache with suEXEC, fcgid and userdir to enhance overall website security.
Everything works expect for useraccounts with a "." between their accountnames. Before using suEXEC and fcgid, this used to work although that practice has been discouraged many years ago.
For example: mydomain.com/~mytest/ works
mydomain.com/~my.test/ doesn't work
The error message that I get is "Bad Request Your browser sent a request that this server could not understand."
Is there a quick workaround to this or I'm I doomed at recreating all the accounts without any accountname separation?
Historically usernames were up to 8 characters long, started with a letter, and contained only lower case letters, underscore, and numbers. Some systems still make this assumption, and that is probably what is catching you out here.

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