Repository: facelessuser/pymdown-extensions

Issue:
pymdown-extensions 10.0 seems to break subdirectory imports
### Description

I've got the following file structure (for clarity, really - to keep imported files clearly separated)

```
docs/                                                                                                                                       
├── parent-file.md                                                                                                                 
├── includes
│   ├── includeA.md
│   ├── includeB.md
└── index.md

```

with the following configuration:

```
- pymdownx.snippets:
      base_path: docs
      check_paths: true
```



This config used to work fine until the update of 10.0 - which i understand will restrict imports to relative paths.

```
...
    base_path: docs
```

in the file `parent.md` - 
```
--8<-- "includes/includeA.md"
...
--8<-- "includes/includeB.md"

```

My path is relative to the parent directory, and contained in the parent directory (which shouldn't be a vulnerability).(everything is within the `./docs/` directory) - yet imports fail.

I've tried several possibilities for base_path (`./docs`, `./docs/`,  `docs/`) - but the only possibility that seems to work is to drop the sub-directory component and change the imports 


```
...
    base_path: docs/includes
```

```
--8<-- "includeA.md"
...
--8<-- "includeB.md"

```

Now i would prefer to keep the original structure for clarity, and to avoid problems when other files are imported (imports are with `imports/includeA.md`) but i'd also not want to enable legacy mode, as in my understanding, that will reenable the vulnerability.



### Version(s) & System Info

- Operating System: linux
- Python Version: 3.10
- Package Version: 10.0

Comments:

Patch:
diff --git a/docs/src/markdown/about/changelog.md b/docs/src/markdown/about/changelog.md
index fdf31a3f..68887d99 100644
--- a/docs/src/markdown/about/changelog.md
+++ b/docs/src/markdown/about/changelog.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 10.0.1
+
+- **FIX**: Regression related to snippets nested deeply under specified base path.
+
 ## 10.0
 
 - **Break**: Snippets: snippets will restrict snippets to ensure they are under the `base_path` preventing snippets
diff --git a/pymdownx/__meta__.py b/pymdownx/__meta__.py
index b8400f7e..3f8370ee 100644
--- a/pymdownx/__meta__.py
+++ b/pymdownx/__meta__.py
@@ -185,5 +185,5 @@ def parse_version(ver, pre=False):
     return Version(major, minor, micro, release, pre, post, dev)
 
 
-__version_info__ = Version(10, 0, 0, "final")
+__version_info__ = Version(10, 0, 1, "final")
 __version__ = __version_info__._get_canonical()
diff --git a/pymdownx/snippets.py b/pymdownx/snippets.py
index 56b03de3..b0582c0f 100644
--- a/pymdownx/snippets.py
+++ b/pymdownx/snippets.py
@@ -163,7 +163,7 @@ class SnippetPreprocessor(Preprocessor):
                     if self.restrict_base_path:
                         filename = os.path.abspath(os.path.join(base, path))
                         # If the absolute path is no longer under the specified base path, reject the file
-                        if not os.path.samefile(base, os.path.dirname(filename)):
+                        if not filename.startswith(base):
                             continue
                     else:
                         filename = os.path.join(base, path)


Test patch:
diff --git a/tests/test_extensions/test_snippets.py b/tests/test_extensions/test_snippets.py
index caa1a1b2..caeeb1fd 100644
--- a/tests/test_extensions/test_snippets.py
+++ b/tests/test_extensions/test_snippets.py
@@ -510,6 +510,34 @@ class TestSnippetsNested(util.MdCase):
             )
 
 
+class TestSnippetsMultiNested(util.MdCase):
+    """Test multi-nested restriction."""
+
+    extension = [
+        'pymdownx.snippets',
+    ]
+
+    extension_configs = {
+        'pymdownx.snippets': {
+            'base_path': os.path.join(BASE),
+            'check_paths': True
+        }
+    }
+
+    def test_restricted_multi_nested(self):
+        """Test file restriction."""
+
+        self.check_markdown(
+            R'''
+            --8<-- "_snippets/b.txt"
+            ''',
+            '''
+            <p>Snippet</p>
+            ''',
+            True
+        )
+
+
 class TestSnippetsNestedUnrestricted(util.MdCase):
     """Test nested no bounds."""