joshp23 / YOURLS-Expiry

YOURLS plugin to define conditions under which links will expire - time and click limited links
GNU General Public License v3.0
35 stars 13 forks source link

postx Fallback URL not working; Prevents URL from expiring. #8

Closed JamoCA closed 5 years ago

JamoCA commented 5 years ago

If I add a postx URL to an expiring shortURL, it continues to work and is not redirecting to the fallback URL.

I'm using Windows Server 2016, IIS and YOURLS v 1.7.2.

After the clock or click expires, the shortURL continues to be listed on the "admin" & "Expiry" pages and click-thrus continue to redirect to the original shortened URL.

I thought that another plugin may be causing problems and disabled every plugin so that "Expiry" was the only plugin enabled and the postx fallback URL still didn't work.

NOTE: The Expiry config page indicates that "YOURLS_UNIQUE_URLS" is set to true, but we've verified that it's actually false and we can successfully generate non-unique URLs.

Are there some other prerequisites for this plugin to work?

JamoCA commented 5 years ago

I think the following (plugin.php; line 73):

$unique = ( 'YOURLS_UNIQUE_URLS' == true )

should be:

$unique = ( YOURLS_UNIQUE_URLS == true )
JamoCA commented 5 years ago

I just noticed that YOURLS 1.7.3 was released 17 days ago. I upgraded and created a new expiring URL w/postx fallback and it still didn't work. (I was hoping that upgrading would fix it.)

joshp23 commented 5 years ago

Correct regarding YOURLS_UNIQUE_URLS, this has been fixed. However, the fallback url problem persists, and I found 2 other bugs in the process.

joshp23 commented 5 years ago

I can confirm that links do indeed expire without any post expiry location, even after applying the YOURLS_UNIQUE_URLS fix.

JamoCA commented 5 years ago

After upgrading to 2.0.1, if I pass {age=1, agemod="min"}, it defaults to 1 day and starts counting down from 24:00:00. I checked in the plugin.php script and not all references were changed in the API and "agemod" values aren't used and the default is set to the "day" unit.

If I set the "expiry" option to "click" and set it to 3, I can watch the counter increase past 3 without every stopping or redirecting to the postX URL. (If I don't use a postX URL, it correctly stops redirecting at the correct interval and redirects to the global fallback page.)

joshp23 commented 5 years ago

After upgrading to 2.0.1, if I pass {age=1, agemod="min"}, it defaults to 1 day and starts counting down from 24:00:00.

I just executed this in my terminal

curl --data "signature=MYSIGNATURE&format=json&action=shorturl&url=https://github.com/joshp23/YOURLS-Expiry/issues/8&expiry=clock&age=1&ageMod=min&postx=https://example.com" https://sho.rt/yourls-api.php  | python -m json.tool

And received the expected result:

{
    "expiry": "1 min expiry set.",
    "message": "https://github.com/joshp23/YOURLS-Expiry/issues/8 added to database",
    "postx": "https://example.com",
    "shorturl": "https://sho.rt/123xx",
    "status": "success",
    "statusCode": 200,
    "title": "postx Fallback URL not working; Prevents URL from expiring. \u00b7 Issue #8 \u00b7 joshp23/YOURLS-Expiry \u00b7 GitHub",
    "url": {
        "date": "2019-02-05 01:50:23",
        "ip": "00.00.00.00",
        "keyword": "123xx",
        "title": "postx Fallback URL not working; Prevents URL from expiring. \u00b7 Issue #8 \u00b7 joshp23/YOURLS-Expiry \u00b7 GitHub",
        "url": "https://github.com/joshp23/YOURLS-Expiry/issues/8"
    }
}

I checked in the plugin.php script and not all references were changed in the API

Where? I changed all instances of mod as a keyword as per your request, and everything seems to work fine. Is $mod a problem for you as well? Incidentally, pull requests are my favorite things.

and "agemod" values aren't used and the default is set to the "day" unit.

Defaulting to day is the correct defaulting behavior if no changes to default settings have been made, and if no value is sent. Try correcting case to ageMod. Maybe YOURLS has a case sensitive API we weren't aware of.

If I set the "expiry" option to "click" and set it to 3, I can watch the counter increase past 3 without every stopping or redirecting to the postX URL. (If I don't use a postX URL, it correctly stops redirecting at the correct interval and redirects to the global fallback page.)

Weird, that behavior was addressed with these last few commits, here is the relevant change https://github.com/joshp23/YOURLS-Expiry/commit/2315acd0e96b76799b6d7fc4f0171c3ac0ba38d3#r32191395 I validated working post-expire fallback links with Ubuntu 18.04 + Nginx before submitting that.

JamoCA commented 5 years ago

Thanks for the case-sensitivity recommendation. (I primarily use ColdFusion + Windows platform and all FORM / URL parameters sent to the server are case-insensitive, but specific case-sensitivity can be retrieved if required.)

I modified the outgoing post parameter to be "ageMod" and it successfully set the value to "min" (versus the default "day").

Thanks for making this 2.0.3 update so quickly. I can verify that the fallback function is correctly working now.