Skip to content

Commit 93bd59b

Browse files
authored
Closes #3220 (#3226)
Be more robust in case of bad URIs.
1 parent 39c2898 commit 93bd59b

File tree

5 files changed

+143
-130
lines changed

5 files changed

+143
-130
lines changed

news/changelog-1.3.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
## Miscellaneous
2222

2323
- Work around pandoc strict checking of `number-offset` type. ([#3126](https://github.com/quarto-dev/quarto-cli/issues/3126))
24+
- Warn instead of crash on bad URI ([#3220](https://github.com/quarto-dev/quarto-cli/issues/3220))

src/core/html.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { pandocAutoIdentifier } from "./pandoc/pandoc-id.ts";
1111
import { isFileRef } from "./http.ts";
1212
import { cssFileRefs } from "./css.ts";
1313
import { HtmlPostProcessResult } from "../command/render/types.ts";
14+
import { warning } from "log/mod.ts";
1415

1516
export function asHtmlId(text: string) {
1617
return pandocAutoIdentifier(text, false);
@@ -19,7 +20,18 @@ export function asHtmlId(text: string) {
1920
export function getDecodedAttribute(element: Element, attrib: string) {
2021
const value = element.getAttribute(attrib);
2122
if (value) {
22-
return decodeURI(value);
23+
try {
24+
return decodeURI(value);
25+
} catch (e) {
26+
if (e instanceof URIError) {
27+
warning(
28+
`Invalid URI '${value}' in attribute '${attrib}' of element '${element.tagName}'`,
29+
);
30+
return value;
31+
} else {
32+
throw e;
33+
}
34+
}
2335
} else {
2436
return value;
2537
}

src/resources/editor/tools/vs-code.mjs

+43-43
Original file line numberDiff line numberDiff line change
@@ -16437,48 +16437,6 @@ var require_yaml_intelligence_resources = __commonJS({
1643716437
description: "The alt text for preview image on this page."
1643816438
}
1643916439
],
16440-
"schema/extension.yml": [
16441-
{
16442-
name: "title",
16443-
description: "Extension title.",
16444-
schema: "string"
16445-
},
16446-
{
16447-
name: "author",
16448-
description: "Extension author.",
16449-
schema: "string"
16450-
},
16451-
{
16452-
name: "version",
16453-
description: "Extension version.",
16454-
schema: {
16455-
ref: "semver"
16456-
}
16457-
},
16458-
{
16459-
name: "quarto-required",
16460-
description: "Quarto version range. See https://docs.npmjs.com/cli/v6/using-npm/semver for syntax details.",
16461-
schema: "string"
16462-
},
16463-
{
16464-
name: "contributes",
16465-
schema: {
16466-
object: {
16467-
properties: {
16468-
shortcodes: {
16469-
arrayOf: "path"
16470-
},
16471-
filters: {
16472-
arrayOf: "path"
16473-
},
16474-
formats: {
16475-
schema: "object"
16476-
}
16477-
}
16478-
}
16479-
}
16480-
}
16481-
],
1648216440
"schema/format-aliases.yml": {
1648316441
aliases: {
1648416442
"epub-all": [
@@ -20139,7 +20097,49 @@ var require_yaml_intelligence_resources = __commonJS({
2013920097
]
2014020098
},
2014120099
$id: "handlers/mermaid"
20142-
}
20100+
},
20101+
"schema/extension.yml": [
20102+
{
20103+
name: "title",
20104+
description: "Extension title.",
20105+
schema: "string"
20106+
},
20107+
{
20108+
name: "author",
20109+
description: "Extension author.",
20110+
schema: "string"
20111+
},
20112+
{
20113+
name: "version",
20114+
description: "Extension version.",
20115+
schema: {
20116+
ref: "semver"
20117+
}
20118+
},
20119+
{
20120+
name: "quarto-required",
20121+
description: "Quarto version range. See https://docs.npmjs.com/cli/v6/using-npm/semver for syntax details.",
20122+
schema: "string"
20123+
},
20124+
{
20125+
name: "contributes",
20126+
schema: {
20127+
object: {
20128+
properties: {
20129+
shortcodes: {
20130+
arrayOf: "path"
20131+
},
20132+
filters: {
20133+
arrayOf: "path"
20134+
},
20135+
formats: {
20136+
schema: "object"
20137+
}
20138+
}
20139+
}
20140+
}
20141+
}
20142+
]
2014320143
};
2014420144
}
2014520145
});

src/resources/editor/tools/yaml/web-worker.js

+43-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/editor/tools/yaml/yaml-intelligence-resources.json

+43-43
Original file line numberDiff line numberDiff line change
@@ -9413,48 +9413,6 @@
94139413
"description": "The alt text for preview image on this page."
94149414
}
94159415
],
9416-
"schema/extension.yml": [
9417-
{
9418-
"name": "title",
9419-
"description": "Extension title.",
9420-
"schema": "string"
9421-
},
9422-
{
9423-
"name": "author",
9424-
"description": "Extension author.",
9425-
"schema": "string"
9426-
},
9427-
{
9428-
"name": "version",
9429-
"description": "Extension version.",
9430-
"schema": {
9431-
"ref": "semver"
9432-
}
9433-
},
9434-
{
9435-
"name": "quarto-required",
9436-
"description": "Quarto version range. See https://docs.npmjs.com/cli/v6/using-npm/semver for syntax details.",
9437-
"schema": "string"
9438-
},
9439-
{
9440-
"name": "contributes",
9441-
"schema": {
9442-
"object": {
9443-
"properties": {
9444-
"shortcodes": {
9445-
"arrayOf": "path"
9446-
},
9447-
"filters": {
9448-
"arrayOf": "path"
9449-
},
9450-
"formats": {
9451-
"schema": "object"
9452-
}
9453-
}
9454-
}
9455-
}
9456-
}
9457-
],
94589416
"schema/format-aliases.yml": {
94599417
"aliases": {
94609418
"epub-all": [
@@ -13115,5 +13073,47 @@
1311513073
]
1311613074
},
1311713075
"$id": "handlers/mermaid"
13118-
}
13076+
},
13077+
"schema/extension.yml": [
13078+
{
13079+
"name": "title",
13080+
"description": "Extension title.",
13081+
"schema": "string"
13082+
},
13083+
{
13084+
"name": "author",
13085+
"description": "Extension author.",
13086+
"schema": "string"
13087+
},
13088+
{
13089+
"name": "version",
13090+
"description": "Extension version.",
13091+
"schema": {
13092+
"ref": "semver"
13093+
}
13094+
},
13095+
{
13096+
"name": "quarto-required",
13097+
"description": "Quarto version range. See https://docs.npmjs.com/cli/v6/using-npm/semver for syntax details.",
13098+
"schema": "string"
13099+
},
13100+
{
13101+
"name": "contributes",
13102+
"schema": {
13103+
"object": {
13104+
"properties": {
13105+
"shortcodes": {
13106+
"arrayOf": "path"
13107+
},
13108+
"filters": {
13109+
"arrayOf": "path"
13110+
},
13111+
"formats": {
13112+
"schema": "object"
13113+
}
13114+
}
13115+
}
13116+
}
13117+
}
13118+
]
1311913119
}

0 commit comments

Comments
 (0)