GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Validate pyexpat SetBase strings (#9581) · RustPython/RustPython@151813d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • crates/stdlib/src
    • pyexpat.rs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎crates/stdlib/src/pyexpat.rs‎

Copy file name to clipboardExpand all lines: crates/stdlib/src/pyexpat.rs
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,11 +1253,15 @@ mod _pyexpat {
12531253
}
12541254

12551255
#[pymethod(name = "SetBase")]
1256-
fn set_base(zelf: &Py<Self>, base: PyStrRef) {
1256+
fn set_base(zelf: &Py<Self>, base: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<()> {
1257+
if base.as_str().contains('\0') {
1258+
return Err(vm.new_value_error("embedded null character"));
1259+
}
12571260
// Store-only compatibility state for xml.sax locator APIs. The
12581261
// xml-rs backend still does not perform Expat-style base URI
12591262
// resolution for external entities.
1260-
*zelf.base.write() = Some(AsRef::<str>::as_ref(&base).to_owned());
1263+
*zelf.base.write() = Some(base.as_str().to_owned());
1264+
Ok(())
12611265
}
12621266

12631267
#[pymethod(name = "GetBase")]

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.