Skip to content

Conversation

@VasekPurchart
Copy link
Contributor

@VasekPurchart VasekPurchart commented Dec 2, 2019

  • bug fix
  • BC break? no

Since Strings::webalize() can be called on user input it should be able to deal with anything or error in a predicable way. But when an malformed UTF-8 input is given currently it results in:

Nette\Utils\RegexpException was expected but got TypeError (strtr() expects parameter 1 to be string, null given)

(i guess this behaved differently before scrict types were added in 3.0.0).

Throwing an exception (the same exception as in other cases such as Strings::replace()) seems reasonable to me.

I am also not sure why the internal handling of PCRE is not used everywhere in calling preg_* is not used everywhere in the file, because there might be of course other problems too?

@VasekPurchart
Copy link
Contributor Author

Travis failures seem to be unrelated to this PR.

@dg
Copy link
Member

dg commented Dec 3, 2019

Thanks

@dg dg merged commit aa00974 into nette:master Dec 3, 2019
@VasekPurchart VasekPurchart deleted the webalize-malformed-utf branch December 3, 2019 21:39
@VasekPurchart
Copy link
Contributor Author

@dg Thanks for merging. As for the other places in Strings where the native preg_ functions are called - do you want them changed as well?

@dg
Copy link
Member

dg commented Dec 3, 2019

I did it 6339ca2

@VasekPurchart
Copy link
Contributor Author

Great, thanks 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants