jdel / sspks

A very simple Synology Package Server, reverse engineered from the official Synology package repository and SynoCommunity.
GNU General Public License v3.0
258 stars 64 forks source link

DS411+II and DS716+II give an Invalid Location error when referring to a sspks repository #16

Closed jorikcaljouw closed 7 years ago

jorikcaljouw commented 7 years ago

I've been trying to add an sspks repository to my DS411+II for a while now. I thought something was wrong with my Synology, but with Synology support we found that the issue is related to sspks. Package Center shows "Invalid Location".

When we run the following curl command, we can see that sspks works correctly for DS411+, but not for DS411+II: curl -L -A "synology_x86_411+ DSM6.1-14902 (package)" --data "package_update_channel=stable&unique=synology_x86_411+&build=14903&language=enu&major=6&arch=x86&minor=1&timezone=Amsterdam" "http://www.jadahl.com/domoticz_stable_6/"

vs

curl -L -A "synology_x86_411+II DSM6.1-14902 (package)" --data "package_update_channel=stable&unique=synology_x86_411+II&build=14903&language=enu&major=6&arch=x86&minor=1&timezone=Amsterdam" "http://www.jadahl.com/domoticz_stable_6/"

Maybe Synology changed something, but I found that the issue is related to the preg_match on line 36 of index.php.

Since the + is a special character for regular expression, this fails. The + should be escaped and I think the following suggestion is a good solution?

Change line 34 from: $unique = trim($_POST['unique']); to $unique = preg_quote(trim($_POST['unique']));

Thanks! Jorik

jorikcaljouw commented 7 years ago

Quick update, the change did not resolve the issue on jadahl's server. So while this is still an issue, it seems my fix does not resolve it. I will perform some more debugging!!

jorikcaljouw commented 7 years ago

The curl command from Synology was not correct for testing. The proposed fix does in fact resolve the issue :-)! A better command for testing if DS411+II works is: curl -L -A "synology_x86_411+II DSM6.1-14902 (package)" --data "package_update_channel=stable&unique=synology_x86_411%2BII&build=14903&language=enu&major=6&arch=x86&minor=1&timezone=Amsterdam" "http://www.jadahl.com/domoticz_stable_6/"

As you can see the + in the unique parameter is replaced with the url-encoded variant: %2B

colin1497 commented 7 years ago

I'm also having an issue with my own repository suddenly giving "Invalid Location". Everything worked a month ago, now it doesn't on my RS814+. Tried applying your suggested change and it didn't fix the issue.

jorikcaljouw commented 7 years ago

Hi Colin, Jadahl applied the fix to his repository and my DS411+II is working great on it. Can you check if your RS418+ accepts his repository? You should be able to add his repo with this URL: http://www.jadahl.com/domoticz_stable_6/

colin1497 commented 7 years ago

Realized my repository wasn't running the updated version, so I applied the fix, but it wasn't the only problem.

Tested http://www.jadahl.com/domoticz_stable_6/ from my RS814+ with no problems.

I actually just switched my repository to the rewritten version that @mbirth proposed here: https://github.com/jdel/sspks/pull/15

And I applied the same fix to that version. I think it's working from the feedback I've gotten: hildinger.us/sspks/

mbirth commented 7 years ago

@colin1497 I'm almost sure the patch wasn't even needed as I only use the device ids to display them on the device list. But then it's all done via the architecture id.

colin1497 commented 7 years ago

@mbirth Thanks. I hadn't actually looked at it closely at all.

mbirth commented 7 years ago

So, this can be closed, then?

jdel commented 7 years ago

the curl command works fine on packages.jdel.org which is using commit c89febd75a5477707437d0689bc80c3ddd770db4