Skip to content

Commit

Permalink
Fixed undefined titles in ru
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Borsuk <[email protected]>
  • Loading branch information
biodranik committed Nov 9, 2023
1 parent 12c17dd commit 0a3fd08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ npm i

## Development

Use `npx wrangler dev` for development using Cloudflare, or `npx wrangler dev --local` for localhost development.
Use `npx wrangler dev` for localhost development.

## Deployment

Expand Down
7 changes: 3 additions & 4 deletions src/ge0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function normalizeZoom(zoom: string): number {
}

const htmlEntityCode = {
' ': '&nbsp;',
' ': '&nbsp;',
'¢': '&cent;',
'£': '&pound;',
'¥': '&yen;',
Expand All @@ -71,7 +71,7 @@ const htmlEntityCode = {
};

function encodeHTML(str: string) {
return str.replace(/[\u00A0-\u9999<>\&''""]/gm, (i) => htmlEntityCode[i]);
return str.replace(/[ ¢£¥©®<>\&'"]/gm, (i) => htmlEntityCode[i]);
}

// Coordinates and zoom are validated separately.
Expand Down Expand Up @@ -104,8 +104,7 @@ export async function onGe0Decode(template: string, url: string): Promise<Respon
const llz = decodeLatLonZoom(encodedLatLonZoom);
let [name, title] = normalizeNameAndTitle(params.length > 1 ? params[1] : undefined);
// XSS prevention.
if (name != kSharedViaOM)
name = encodeHTML(name);
if (name != kSharedViaOM) name = encodeHTML(name);
title = encodeHTML(title);

template = replaceInTemplate(template, {
Expand Down

0 comments on commit 0a3fd08

Please sign in to comment.