WordPress.org

Forums

Latest Tweets Widget
[resolved] Swedish characters in hashtag breaks linkify (8 posts)

  1. dotnordic
    Member
    Posted 1 year ago #

    The // linkify #hashtags part of twitter_api_html doesn't seem to be capable of handling Swedish characters å, ä, ö. It cuts the tag when those characters appear.

    I'm guessing the preg_replace pattern needs to be modified?

    Thanks in advance!

    https://wordpress.org/plugins/latest-tweets-widget/

  2. dotnordic
    Member
    Posted 1 year ago #

    I changed the preg pattern in twitter-api-utils.php line 29 to / +#(\p{Xwd}*)/u which seems to work. Any chance you could incorporate something like this in the next update of the plugin?

  3. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for this. I've never been sure of what characters *should* be allowed in a hashtag. This post is 4 years old, but the point still seems to stand.

    I suppose I had assumed that the WordPress esc_html call would escape accented characters in advance of the preg_replace call. Clearly you are right and this is not the case.

    I will look into this and will if possible match the exact syntax that twitter.com uses, if I can find it. I have looked before and I have given up.

    I'm hesitant to simply implement your fix, on two points. Firstly, I'm unsure if all WordPress users will have Unicode property support in their PCRE library and secondly I'm embarrassed to say I don't understand your pattern. Could you explain what property codes the Xwd set refers to, please?

  4. dotnordic
    Member
    Posted 1 year ago #

    I didn't write the pattern myself I looked through a whole bunch of different ones, picked out a few ones that made sense to me and tried them out. This one I ended up with is from here

    http://stackoverflow.com/questions/22098426/prevent-preg-replace-replacing-special-characters

    It says that "\p{Xwd} has the same meaning that \w with all unicode letters and number and underscores."

    I understand your concern! Maybe one could add a settings checkbox or something along those lines to allow unicode support. That way people can tick or untick it depending on whether it works with their systems.

  5. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    I would sooner detect for support than add more checkboxes people won't understand or need to be bothered with.

    I'll see what I can do when I can find time. I'm glad your fix works for you, but I'll need to test it thoroughly before adopting it. I will report back here if and when any change is deployed.

  6. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    The current development version (which will become 1.1.0) has some fixes including better linkifying using actual entity data from twitter. Give it a try -

    Direct link to zip:
    http://downloads.wordpress.org/plugin/latest-tweets-widget.zip

  7. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Can anyone confirm whether this is resolved? Live version has various changes regarding linkifying.

  8. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Marking as resolved in the absense of a follow-up. The plugin uses official twitter hashtag metadata now anyway, so if there's still a bug it's a new issue now anyway.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.