Jump to content

The unicode in urls and btoa() problem usage for v4.7.16


Go to solution Solved by Stuart Silvester,

Recommended Posts

After upgrade we've noticed the new btoa() function and error "failed to execute btoa()" in global_global_core.js
As a result, pagination for cyrillic urls stopped working. 
See https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem

As a temporary solution we implemented the convertion between UTF-8 and single-byte representations before call btoa(), like

Quote

    const toBinaryStr = url => {
        const encoder = new TextEncoder();
        const charCodes = encoder.encode(url);
        const binString = Array.from(charCodes, (byte) => String.fromCodePoint(byte), ).join("");
        return binString;
    };
   <...>
    this._stateKey = `table${btoa(toBinaryStr(this.scope.attr('data-baseurl') ? ips.utils.url.pageParamToPath(this._cleanUpURL(this.scope.attr('data-baseurl')), this._pageParam, 1) : ''))}`;

Edited by Tikhonov Ivan
Link to comment
Share on other sites

Would you, please, fix this core bug of global_global_core.js soon?
It is inconvenient to apply above custom patch every time after clearing system caches. I believe every forums with non-Latin topic urls are affected.

Link to comment
Share on other sites

16 minutes ago, Jim M said:

Please ensure that you have applied the latest release and all patches. I have tagged a developer to review what you have posted though.

Thanks, Jim. That's the point of latest release as well, compared with v4.7.15 the btoa() function appeared in core java-script and utf-8 character string is unacceptable as a btoa() argument.

Link to comment
Share on other sites

  • Solution

We have released a patch to address this issue. Please go to AdminCP > System > Support and apply the patch from the first/top left box. If you do not see an option to install the patch, you already have the latest release. Additionally, as previously noted, enabling URL Rewriting will also fix this issue.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...