BUG: Clippings obtained using obsidian clipper contain escaped double quotes

#977 · open · 0 comments

View on GitHub ↗

bluelephant825

### Is this issue related to missing content or incorrect conversion to Markdown? - [x] No. This is definitely a Web Clipper bug. ### Have you reviewed the troubleshooting instructions? - [x] I have reviewed the [Troubleshooting instructions](https://help.obsidian.md/web-clipper/troubleshoot). ### Operating system macOS 27.0 ### Browser Dia 1.50.1 (Chromium) ### Web Clipper version 1.7.1 ### Obsidian version 1.12.7 ### Describe the bug Clippings obtained using the obsidian clipper contain escaped double quotes, e.g. Researchers at OpenAI used 10,000 autonomous AI agents to prove a \"singularity\" exists in the Navier-Stokes equations, which describe fluid flow. **Root Cause** When clipping the Quanta Magazine article, the LLM Interpreter returned a summary containing quotes (e.g. “singularity” represented as JSON-escaped \"singularity\"). Two issues caused those escaped quotes to leak into the saved clipping: Destructive JSON Sanitization & Flawed Fallback Regex: In src/utils/interpreter.ts, sanitizeJsonString replaced all newlines with literal \n, which broke valid multiline JSON formatting and forced parseLLMResponse into its regex fallback. The regex fallback re-escaped all quotes (.replace(/"/g, '\\"')) prior to JSON.parse, leaving literal backslash quotes (\") inside the parsed text values. Missing Normalization in Frontmatter & Variable Injections: Values passed through replacePromptVariables and YAML frontmatter builders in src/utils/shared.ts did not normalize pre-escaped quotes \", leading to double escaping (\\\") in YAML and literal \" in note bodies. **Solution** Robust JSON Parsing in src/utils/interpreter.ts: Strips Markdown code fences (```json ... ```) and attempts clean JSON.parse first without destructive regex replacements. If fallback regex extraction is needed, valid JSON string decoding JSON.parse('"' + content + '"') is used instead of string replacement. Cleaned output values by normalizing stray \" to unescaped " before caching and rendering. Frontmatter Quote Normalization in src/utils/shared.ts: In generateFrontmatter and generateFrontmatterObject, normalized pre-escaped quotes (item.replace(/\\"/g, '"')) to prevent double-escaping in metadata properties. Automated Tests: Added unit test suites in src/utils/interpreter-gemini.test.ts and src/utils/shared.test.ts covering quoted strings, markdown code blocks, and multiline responses. Verified that all unit tests (230 passing) and production extension builds (Chrome, Firefox, and Safari) compile cleanly. ### Expected behavior Double quotes should not be escaped, i.e. preceded by \. ### URLs where the bug occurs https://www.quantamagazine.org/ai-has-solved-one-of-maths-1-million-millennium-prize-problems-20260908/ ### To reproduce 1. Go to https://www.quantamagazine.org/ai-has-solved-one-of-maths-1-million-millennium-prize-problems-20260908/ 2. Click on 'Add to Obsidian' 3. See error ### Your template file ```json # {{title}} {{ "If the web article is in English, write '## Summary'. If the web article is in another language, write '## ' followed by the translation of 'Summary' in the same language as the web article." }} {{ "Describe the most interesting aspect of this article as a statement in the same language as the original web article." }} {{ "If the web article is in English, write '## Headlines'. If the web article is in another language, write '## ' followed by the translation of 'Headlines' in the same language as the web article." }} {{ "Provide bulleted headlines as one-line, bolded declarative statements ending in a period, followed by at most 2 supporting sentences, all in the same language as the original web article." }} {{ "If the web article is in English, write '## Mentions'. If the web article is in another language, write '## ' followed by the translation of 'Mentions' in the same language as the web article." }} {{ "Provide a bulleted list of - People, - Places, - Events, - Numbers, - Things and - Concepts, as tags in the same language as the original web article. Ignore navigation elements." }} --- {{ contentHtml | replace:'<web-highlight':'MARKSTART' | replace:'</web-highlight>':'MARKEND' | markdown | replace:'MARKSTART':'<mark' | replace:'MARKEND':'</mark>' }} ```

Comments