Jump to content

adrian

PW-Moderators
  • Posts

    10,897
  • Joined

  • Last visited

  • Days Won

    348

Everything posted by adrian

  1. @matjazp - can you confirm this on your setup? If this is reproducible it sounds like we need to file an issue as it's not related to this module.
  2. Did you change it to en_US.UTF-8 to fix it, or something else?
  3. All those "?" suggest to me that maybe there is a UTF-8 problem going on but I am not sure how to debug further at this point. Anyone out there with any other ideas?
  4. OK, so it's pretty clear that the: if(mb_strpos($value, $from) !== false) { is failing.When I do: $filename = '"Test ä".png'; $pageFiles = new Pagefiles($page); d($pageFiles->cleanBasename($filename, false, true, true)); I get a dump returned showing: This is because it is finding the ä in the filename and doing a mb_eregi_replace on it to convert from "ä" to "a". Does it make any difference if you change "mb_strpos" to "strpos" ? What about removing that conditional altogether so that all replacements are executed regardless of whether the $from is found. So it would be like this - note that I have commented out the conditional. foreach($replacements as $from => $to) { //if(mb_strpos($value, $from) !== false) { bd($from .' => ' . $to, $value); $value = mb_eregi_replace($from, $to, $value); //} }
  5. If that is the only thing that is being dumped, then it sounds like there is an issue with the: foreach($replacements as $from => $to) { loop because there are a couple of bd() calls in there also. It would be helpful to figure out what is failing there. This should help: if($beautify && $needsWork) { bd(1); if($beautify === self::translate && $this->multibyteSupport) { bd(2); $value = mb_strtolower($value); if(empty($replacements)) { bd(3); $configData = $this->wire('modules')->getModuleConfigData('InputfieldPageName'); $replacements = empty($configData['replacements']) ? InputfieldPageName::$defaultReplacements : $configData['replacements']; } foreach($replacements as $from => $to) { bd(4); if(mb_strpos($value, $from) !== false) { bd(5); bd($from .' => ' . $to, $value); $value = mb_eregi_replace($from, $to, $value); bd($value); } } } if(function_exists("\\iconv")) { $v = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value); if($v) { bd($value, 'ICONV'); $value = $v; } } $needsWork = strlen(str_replace($allowed, '', $value)); } Can you try that and let me know which of the 1, 2, 3, 4, 5 bd() calls are output? We are looking to see if commenting that out changes the returned filename, so you could test an actual file upload or you could run that cleanBasename test in the Console again. Either will be fine.
  6. @PWaddict - did you have any success with that modified code in Sanitizer.php - did the bd() calls work? Another thing to try would be to comment out that iconv code completely: /* if(function_exists("\\iconv")) { $v = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value); if($v) { $value = $v; } }*/ so we can see what is returned without it getting involved.
  7. Yeah, it depends on when the bd() call is made. Tracy is now always the first site module loaded by PW (thanks to a recent update by Ryan), but when it comes to the PW core and core modules I don't have any control over that - sometimes you'll have success and other times you'll get that error. For me though they have been working in those spots in Sanitizer.php. I guess the name() method is being called by the core at some point before Tracy is loaded which is why it's not working for you?
  8. @Zeka - could you please add to this ongoing issue: https://github.com/processwire/processwire-issues/issues/408
  9. The code block I posted doesn't change any behavior - it just adds bd() calls so that will can see what is going on in that function. Once you restart does it continue to work until you do something specific or does it seem to randomly stop working?
  10. Here's a working function for doing this. I know without being in the core it's not much use to you, but thought it was worth referencing: https://github.com/adrianbj/ProcessModuleToolkit/blob/09b437d888c270ffe01f3a80fc5dccab3136e42e/ProcessModuleToolkit.module#L1278
  11. @PWaddict - it might also be useful to see what these return. Some are repeats from before, but I would like to see all of these please. $filename = '"Test ä".png'; $pageFiles = new Pagefiles($page); d($pageFiles->cleanBasename($filename)); d($pageFiles->cleanBasename($filename, false, true, true)); d($sanitizer->filename($filename, Sanitizer::translate)); d($sanitizer->pageName($filename, Sanitizer::translate));
  12. Thanks @matjazp for testing that - much appreciated. It seems like everything is working as expected for you.
  13. I don't have access to a Windows machine dev environment at the moment. It might be related I suppose. I would have thought this issue would have come up before though because the cleanBasename method is what PW uses when uploading images, which is the reason I'd like to stay with this approach if I can, rather than the old pageName I was using before. In terms of how you could debug this, in that block of code I linked to, I'd want to know that mb_strpos, mb_eregi_replace and iconv calls are returning the same values on the Windows box that they are on linux. I would try this: if($beautify && $needsWork) { if($beautify === self::translate && $this->multibyteSupport) { $value = mb_strtolower($value); if(empty($replacements)) { $configData = $this->wire('modules')->getModuleConfigData('InputfieldPageName'); $replacements = empty($configData['replacements']) ? InputfieldPageName::$defaultReplacements : $configData['replacements']; } foreach($replacements as $from => $to) { if(mb_strpos($value, $from) !== false) { bd($from .' => ' . $to, $value); $value = mb_eregi_replace($from, $to, $value); bd($value); } } } if(function_exists("\\iconv")) { $v = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value); if($v) { bd($value, 'ICONV'); $value = $v; } } $needsWork = strlen(str_replace($allowed, '', $value)); } which should result in something like this which shows the replacement ä => a that is being made and with the final filename and whether the iconv call changes it further or not.
  14. Thanks, although not what I was hoping for ? I don't know how to debug this without being able to access your system. I am pretty sure it's in $sanitizer->nameFilter() which is called by many other methods. Have you manually edited the PageName character replacements? It seems that if I remove the needed ones from that and I disable iconv, then I can get the same result you are getting. Would you be up for trying to dig into that nameFilter method and see where it's failing for you? I think it's somewhere in this block: https://github.com/processwire/processwire/blob/a0570bb2a0919ddc38487f1adbb190f9f9ab90f2/wire/core/Sanitizer.php#L171-L186
  15. I don't think I have seen it before either, but on the site in question, it is triggered by the "Show Page IDs" option. If I turn that off, it works as expected.
  16. Sorry I didn't catch that ? So for some reason your install is behaving differently. I think I have narrowed it down to multibyte support or iconv. Could you please run these in the console and let me know what you get: d(function_exists("mb_internal_encoding")); d(function_exists("\\iconv"));
  17. @PWaddict - thanks for checking that code in the Console, but it looks the same as what I am seeing, so I can't figure out why you're getting a different result returned from the module. Not sure where to go from here other than asking you to test on another PW install.
  18. This is interesting: Are you seeing the first, rather than the second result? See the last commit where those booleans are passed to the cleanBasename() method: https://github.com/adrianbj/CustomUploadNames/commit/9428a18c4cf67a40c7ef6bd6b63ae600a28086e3 Could you please check that the version you are using has those lines and also please test that code in the Tracy console: $pageFiles = new Pagefiles($page); d($pageFiles->cleanBasename('"Test ä".png')); d($pageFiles->cleanBasename('"Test ä".png', false, true, true));
  19. Weird, that filename format patter for me returns: test_a_1545255464.jpg which should be exactly what we expect - correct?
  20. You can use: $input->post('reset-button') or $input->post->{'reset-button'} This is not a PW issue, but rather a PHP one - you just can't use hyphens like that. That is why PW field names use underscores and not hyphens.
  21. @PWaddict - I know you'd like me to just revert to that previous version but I would like to figure out why it seems to be working ok for me and not you. Can you please post your settings for the rename rule and an example of a field value that is causing htmlentities to be replaced with underscores.
  22. Go to Modules > Core > AdminThemeUiKit. You can choose the Gravatar option or you can edit the user template to add an images field which can be used for manually added images. Remember that the user template is a system template so you need to go to Setup > Templates > Filters > Show System Templates.
  23. Actually, I messed up that reversal, but I decided to investigate the issue you're having with 1.2.3 and I can't reproduce. This is what happens for me in a repeater - note that the ä is replaced with an "a" as expected. I don't think it should matter, but what version of PW are you running?
  24. Thanks for noticing that - I have reverted that change and bumped the version number to 1.2.4 to make sure anyone who upgraded to 1.2.3 sees that there has been an update.
  25. @PWaddict - I just committed another update which makes use of PW's core cleanBasename method for generating the final filename. I think this should be an improvement in certain situations. Please let me know if you have any problems with it.
×
×
  • Create New...