mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Parse escape sequences instead of using replace
That way we can warn about invalid sequences. Also, the previous code had at least one subtle bug (`\\\\'`).
This commit is contained in:
parent
bc798c544c
commit
ea92838cf3
7 changed files with 76 additions and 21 deletions
|
@ -23,7 +23,7 @@ from dataclasses import dataclass
|
|||
from enum import Enum
|
||||
|
||||
from .gir import *
|
||||
from .utils import Colors
|
||||
from .utils import Colors, escape_quote
|
||||
from .xml_reader import Element, parse, parse_string
|
||||
|
||||
__all__ = ["decompile"]
|
||||
|
@ -253,15 +253,6 @@ def decompiler(tag, cdata=False):
|
|||
return decorator
|
||||
|
||||
|
||||
def escape_quote(string: str) -> str:
|
||||
return (
|
||||
string.replace("\\", "\\\\")
|
||||
.replace("'", "\\'")
|
||||
.replace('"', '\\"')
|
||||
.replace("\n", "\\n")
|
||||
)
|
||||
|
||||
|
||||
@decompiler("interface")
|
||||
def decompile_interface(ctx, gir):
|
||||
return gir
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue