sho.rt/a-badmin/index.phpsho.rt/ab shown where sho.rt/a-b used to besho.rt/a-b nor sho.rt/ab successfully redirect to targetsomething wrong happened while deleting :/You're surprised that deactivating the Allow Hyphens in Short URLs plugin breaks short URLs containing hyphens?
@dgw not surprised at all but thought that it might be confusing for other users 🤷♂️
I agree there's something to be improved here: at least you should be able to delete such a link or do something with it. I'll look into things.
I have experimented with so many non-default characters, I am now wondering what I would do when a major new update is released!
@Sushubh - Wouldn't it be better to make a copy of the Allow Hyphens in Short URLs plugin? Then adjust it to make your own plugin for your "many non-default characters." In your config file add a Constant with a list of "non-default characters." separated by a specified standard character from the 36 base. For example, using the number "8" as a separator:
define( 'NON_DEFAULT_CHARACTERS', '-8~8!8@8#8$8%8^8&8*8(8)8_8+' );
_Note: I am not saying any of those "non-default characters" would actually work!_
Then, within a function in your plugin, you can explode these into an array.
$extra = explode( "8", NON_DEFAULT_CHARACTERS );
$extra would then be a nice array of all your "non-default characters" you could use in your plugin.
echo $extra[0]; // -
echo $extra[1]; // ~
echo $extra[6]; // ^
You could then experiment by simply changing the config file.
Pop VeKind
PS: Did you consider the value of the extra characters?
Are you running a goo.gl or bit.ly where these may be important? If you are you will likely need more resources an more knowledge to make it work.
Are you running a private YOURLS? Likely the defaults are plenty.
Do you just want to see if it can be done? Will it work? Then you are near and dear to my heart. Good luck, it is the journey that matters. Make the above suggested any extra characters plugin and enjoy!
I am actually using this plugin:
http://github.com/josheby/yourls-additional-charsets
I was more concerned about a major update that would break compatibility with older plugins (something i am soon going to experience with xenforo2 release)!
@ozh - Just a flash idea...
Perhaps leave the Admin basically the same with the added ability to delete any entry.
Likewise, when the shortened URL was serviced, maybe we should check anything against the DB.
For example, we add the keyword 123-XYZ to the Database. Then remove the hyphen plugin. 123-XYZ could be allowed to work IF it is already in the DB, just no new hyphen keys would be allowed to be added.
Just a thought.
@Sushubh - Ah yes, that is always a problem. How to "Future Proof" a program/plugin? It cant be done.
yourls-additional-charsets looks good though. I especially like that you can supply your own Custom Charset. Actually, I like simple things and that is all I would use.
I would not worry about this breaking in future releases of YOURLS. It uses a standard hook - 'get_shorturl_charset' - which appears to be designed in the core files for just this sort of purpose.
Pop VeKind
I've been chewing on this problem for a while. I'm working on a Settings Page to replace the constants in the config file. It is basically the same as, "What if I change my settings from 62 to 36?" (uppercase, lowercase, and numbers, to only lowercase and numbers?) It also fails on the uppercase letters.
I believe _setting changes should not cause failures._
The solution is simple, make all entries in the DB legal. This would mean setting changes would not break anything. If you had settings of 62, plus hyphens, plus exclamation points and a keyword
Something-Special! Then changed to a strict 36 only, your keyword Something-Special! would continue to work.
If it is in the DB and you don't want it, just delete it.
Use the restriction settings only in the _making_ of short URLs during _automatic_ mode.
When adding or editing a short URL _MANUALLY,_ you should have the power of adding characters outside of the _restricted range_ prescribed in settings for _automatic_ URLs. Perhaps with a warning!
@PopVeKind your 1200 word comment is equal to what I said earlier here and in other issues: one should be able to modify a link from a different charset, and link created with a once valid charset should remain valid. At this point, what we need is a PR, not opinions.
I am looking at how to make a PR for this problem. I wondered if other characters may be involved?
To quote section 2.3 of RFC 3986: (http://www.ietf.org/rfc/rfc3986.txt) "Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase(A-Z), lowercase(a-z), decimal digits(0-9), hyphen(-), period(.), underscore(_), and tilde(~)."
Periods(.) may be problematic in some advanced YOURLS as they could be confused with file names like somefile.php or robots.txt
There is a plugin that allows the use of the slash (/). This is not even an unreserved character and does conflict with other plugins or colocated programs.
For redirection, I can see no reason why uppercase (A-Z) lowercase (a-z), decimal digits (0-9), hyphen (-), underscore (_) and tilde (~) could not just be passed to the DB and allowed to pass or fail based on being in the DB.
Anyone deciding to use a period (.) or slash (/) or any other character, should be advised to do so at their own risk as these are advanced options that may conflict with other plugins or programs.
What non-standard (a-z, A-Z, 0-9) characters do you use?
This should solve the 'Allow Hyphens in Short URLs' problem.
Created simple plugin to allow period in short URL period-in-urls.zip
Closing, superseded by 2646
@parisek how tf did you upload a zip file here? :)
Fixed in current master.
Most helpful comment
An Evolving Idea...
I've been chewing on this problem for a while. I'm working on a Settings Page to replace the constants in the config file. It is basically the same as, "What if I change my settings from 62 to 36?" (uppercase, lowercase, and numbers, to only lowercase and numbers?) It also fails on the uppercase letters.
I believe _setting changes should not cause failures._
DB Entries Are Legal
The solution is simple, make all entries in the DB legal. This would mean setting changes would not break anything. If you had settings of 62, plus hyphens, plus exclamation points and a keyword
Something-Special!Then changed to a strict 36 only, your keywordSomething-Special!would continue to work.If it is in the DB and you don't want it, just delete it.
Automatic Only
Use the restriction settings only in the _making_ of short URLs during _automatic_ mode.
Allow Manual Override
When adding or editing a short URL _MANUALLY,_ you should have the power of adding characters outside of the _restricted range_ prescribed in settings for _automatic_ URLs. Perhaps with a warning!