Skip to content

Fix - Url encoding of version numbers#31

Closed
mad-briller wants to merge 1 commit intocode-lts:mainfrom
mad-briller:fix.url-encoding
Closed

Fix - Url encoding of version numbers#31
mad-briller wants to merge 1 commit intocode-lts:mainfrom
mad-briller:fix.url-encoding

Conversation

@mad-briller
Copy link
Contributor

Semver supports adding build information to version numbers using +; 2.0.0+1.

Within urls, + must be encoded as %2B, as + is interpreted as a space character.

Doctum assumes that version numbers will be safe to use in urls without encoding, as such using build information in a version causes the version-switcher to route to an incorrect url.

This PR aims to fix that (forgive me for i am new to twig).
It also fixes a few tests that were not passing when i cloned the repo and ran them.

Let me know how you feel about this change, thanks.

. 'with API information:' . "\n"
. "\n"
. ' <info>php ./vendor/bin/phpunit parse config/symfony.php</info>' . "\n"
. ' <info>php vendor/bin/phpunit parse config/symfony.php</info>' . "\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why you changed that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are the tests i mentioned were failing when i cloned the package, not sure whether you preferred to have the ./ or not so i just updated the tests to pass according to what was expected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well as you can see it fails our CI with the change you made
https://github.com/code-lts/doctum/pull/31/checks?check_run_id=3388964589#step:7:75

I am not really sure why this change is made, probably because you did not use ./vendor/bin/phpunit as a launch command or use the composer run phpunit command :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh yeah, i used php vendor/bin/phpunit out of habit
my bad on that one sorry

<select class="form-control" id="version-switcher" name="version">
{% for version in project.versions %}
<option value="{{ path('../' ~ version ~ '/index.html') }}" data-version="{{ version }}">{{ version.longname }}</option>
<option value="{{ path('../' ~ version.urlEncoded ~ '/index.html') }}" data-version="{{ version }}">{{ version.longname }}</option>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you d'or the patch, I will try to find a way to escape this using twig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, i'm not precious about the patch being merged, only that it works for our use case

thanks for your amazing utility, really impressed with how quick and simple it was to use!

Copy link
Member

@williamdes williamdes Aug 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you !
This tool was previously named Sami but I really improved it since I took back maintenance in 2020.
So some credit for the amazingness goes to the original author ;)

@williamdes williamdes changed the title FIX: Url encoding of version numbers. Fix - Url encoding of version numbers Aug 21, 2021
@williamdes
Copy link
Member

By the way your GitHub seems not to know your email From: Brad Miller <brad@hallnet.co.uk> (https://github.com/code-lts/doctum/pull/31/commits/cde55bc86de21056b107ebdfa2bb4626123febcf.patch)

Maybe this is a git misconfiguration, just wanted to let you know ;)

@williamdes williamdes self-assigned this Aug 21, 2021
<select class="form-control" id="version-switcher" name="version">
{% for version in project.versions %}
<option value="{{ path('../' ~ version ~ '/index.html') }}" data-version="{{ version }}">{{ version.longname }}</option>
<option value="{{ path('../' ~ version.urlEncoded ~ '/index.html') }}" data-version="{{ version }}">{{ version.longname }}</option>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<option value="{{ path('../' ~ version.urlEncoded ~ '/index.html') }}" data-version="{{ version }}">{{ version.longname }}</option>
<option value="{{ path('../' ~ version|url_encode ~ '/index.html') }}" data-version="{{ version }}">{{ version.longname }}</option>

https://twig.symfony.com/doc/3.x/filters/url_encode.html

Could you apply this and revert the other changes please ?

@williamdes williamdes added this to the v5.4.2 milestone Aug 21, 2021
@mad-briller
Copy link
Contributor Author

By the way your GitHub seems not to know your email From: Brad Miller <brad@hallnet.co.uk> (https://github.com/code-lts/doctum/pull/31/commits/cde55bc86de21056b107ebdfa2bb4626123febcf.patch)

Maybe this is a git misconfiguration, just wanted to let you know ;)

woops, i made the change on my work pc and not my personal, good spot there!

Thanks for your input on the url_encode filter; i saw that in the docs but i wasn't sure it could be used when string concatenating like that.

I'll recreate a PR with the correct changeset, email and sign the commits and post it that way instead of modifying this one.

@williamdes williamdes reopened this Aug 22, 2021
@williamdes williamdes closed this Aug 22, 2021
@williamdes williamdes assigned williamdes and unassigned williamdes Aug 22, 2021
@williamdes williamdes added the invalid This doesn't seem right label Aug 22, 2021
@williamdes williamdes removed this from the v5.4.2 milestone Aug 22, 2021
@williamdes
Copy link
Member

Duplicate of #32

@williamdes williamdes marked this as a duplicate of #32 Aug 22, 2021
@williamdes
Copy link
Member

Duplicate of #32

@williamdes
Copy link
Member

I missed that you closed it, normally you do not need to do that, a simple force push will do the trick
Marked it properly as duplicating the right one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Development

Successfully merging this pull request may close these issues.

2 participants