question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

V8: Lowercase media-path hardcoded in regex

See original GitHub issue

We had a strange issue with a Umbraco 8.4-site where images uploaded would not be selectable in a Media Picker when “select only images” was activated.

When I looked closer at it, the “Media Grid” is setting up the selectable-state based on the property mediaEntity.metaData.MediaPath which was always null in our case. It also turns out that all rows in the umbracoMediaVersion-table had the value “null” for the path-column.

After some digging around it turned out the we’ve had this setting in web.config

<add key="umbracoMediaPath" value="~/Media" />

Note the uppercase M in Media, then when the MediaFactory is trying to use regex to find a media-url inside a property value this fails since the regex MediaPathPattern is hardcoded to /media (lowercase).

https://github.com/umbraco/Umbraco-CMS/blob/853087a75044b814df458457dc9a1f778cc89749/src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs#L13

The same would also be true if one where to rename the media-folder to something like “assets”, then this regex would not work, umbracoMediaVersion.parth would be null and the images would not be selectable in the “Image-Media-Picker” or in the RTE/Grid so it’s not just a matter of making it case-insensible, it needs to respect the settings in web.config.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nul800sebastiaancommented, Jan 13, 2020

Yep, should do. Farewell Regex! 👍

This will be released in 8.6.0 @enkelmedia - https://github.com/umbraco/Umbraco-CMS/issues/6324

1reaction
enkelmediacommented, Dec 11, 2019

Haha =D I can’t blame an upgrade from 4.5.2 =D But I guess that you’re right, it probably something that has just been around since before Justin Bieber was famous 😉

Sounds like a plan! I’ll have a look at the regex tomorrow, seems like it should be quite straight forward, some small questions:

  1. Should I use SystemDirectories.Media to get the configured media-folder?
  2. What do we think about using RegexOptions.IgnoreCase to avoid issues with casing in the future?

Another thing that is somewhat related is that the full path to media-files are stored in different places (ie umbracoMediaVersion.path), if someone was to change the media-folder after files have been created you would end up in a “bad place” - at the same time - it’s probably not a huge use case, but anyway - let me know if we should create an issue reg. this to keep it in the backlog.

Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

A regular expression that replaces a group with hard coded ...
1 Answer 1 ... Basically, as the regular expressions defined, it is not possible. By definition, regular expressions match the patterns in the ......
Read more >
RegExp v flag with set notation and properties of strings
The new RegExp `v` flag enables `unicodeSets` mode, unlocking support for extended character classes, including Unicode properties of ...
Read more >
The Complete Guide to Regular Expressions (Regex)
A Regular Expression – or regex for short– is a syntax that allows you to match strings with specific patterns. Think of it...
Read more >
Regular Expression (Regex) Tutorial
(Range Expression): Accept ANY ONE of the character in the range, e.g., [0-9] matches any digit; [A-Za-z] matches any uppercase or lowercase letters....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found