# SSO-Weiterleitung schlägt bei nicht-lateinischen Zeichen fehl

**URL:** https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632
**Category:** WordPress
**Created:** [8. November 2018 um 20:29 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632 "2018-11-08T20:29:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [8. November 2018 um 20:29 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/1 "2018-11-08T20:29:21Z")

</div>

Enabling Discourse as SSO provider (in wordpress but that is unrelated) doesn’t work when setting the redirect paramenter to non-latin chars. for example this works:

`https://www.my_wordpress_website.com/?discourse_sso=1&redirect_to=https://www.my_wordpress_website.com/AAAA/`

but this doesn’t work:

`https://www.my_wordpress_website.com/? discourse_sso=1&redirect_to=https://www.my_wordpress_website.com/אאאא/`

by “doesn’t work” i mean that the bad url just redirects to an “Oops error page” in Discourse

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [8. November 2018 um 22:08 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/2 "2018-11-08T22:08:50Z")

</div>

Use the transliterated URL characters instead. I wouldn’t expect unicode to work in that field.

`https://www.my_wordpress_website.com/%D7%90%D7%90%D7%90%D7%90/`

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [8. November 2018 um 22:41 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/3 "2018-11-08T22:41:28Z")

</div>

Thanks, but Wordpress creates that url via this discourse plugin shortcode [discourse\_sso\_client login=‘Login here’]  
The redirect URL is automatically set to the page in which the shortcode was embedded.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [8. November 2018 um 23:13 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/4 "2018-11-08T23:13:33Z")

</div>

You can add a redirect parameter to the shortcode:

```plaintext
[discourse_sso_client login='Login Through the Forum' redirect=https://wordpress.example.com/%D7%90%D7%90%D7%90%D7%90/]

```

That will create a link like this:

```plaintext
<a href="https://wordpress.example.com/?discourse_sso=1&redirect_to=https://wordpress.example.com/%D7%90%D7%90%D7%90%D7%90">Login Through the Forum</a>

```

You can also manually create a login link instead of using the shortcode. It needs to have the following query parameters:

```plaintext
?discourse_sso=1&redirect_to=https://example.com/your-wordpress-page

```

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [8. November 2018 um 23:20 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/5 "2018-11-08T23:20:30Z")

</div>

I am aware that I can pass the redirect string into the shortcode, but that is not always practical. For example in my case (which I think is common), the shortcode is embedded in a sidebar shared in _all_ pages of the website. So overriding the redirect means that users will never be redirected to the right page.

I guess i could write my own shortcode for that somehow… anyway, thanks for the answer and please consider this a feature request to support wordpress with unicode urls 🙂

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [30. November 2018 um 21:04 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/7 "2018-11-30T21:04:15Z")

</div>

@gerald is right, the plugin does not deal properly with URL and Unicode characters. I’m helping him on this matter.

After investigating, it seems you need to encode properly the URL before sending the request: [wp-discourse/lib/sso-client/query-redirect.php at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/blob/master/lib/sso-client/query-redirect.php#L87-L99)  
Possible and working suggestion: `utf8_uri_encode($redirect_to)`  
If you don’t encode, Discourse will not be happy and will error that URI must be ASCII only.

Another place to fix is when the plugin receives the response: [wp-discourse/lib/sso-client/client.php at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/blob/master/lib/sso-client/client.php#L382-L388)  
I’m not totally sure why `urldecode` and `sanitize_text_field` is used before the string is decoded, but once decoded, the `sanitize_text_field` call on the URL will strip all the encoded characters.  
Possible suggestion: `urldecode` needs to be called before.

So far, those fixes seem to fix the issue gerald had.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [30. Dezember 2018 um 21:04 UTC](https://meta.discourse.org/t/sso-redirect-fails-for-non-latin-chars/101632/8 "2018-12-30T21:04:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
