The following changes were made by the replace_file_content tool to: /root/aadharbot/aadhaar_service.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -135,7 +135,7 @@ } res.status(400).json({ status: 'error', message: 'Captcha generation failed', details: data }); } catch (e) { - res.status(500).json({ status: 'error', message: e.message }); + res.status(500).json({ status: 'error', message: sanitizeError(e.message) }); } }); @@ -149,7 +149,7 @@ const cleanCaptcha = ocrText.replace(/[^a-zA-Z0-9]/g, ''); return res.json({ status: 'success', captchaValue: cleanCaptcha }); } catch (e) { - res.status(500).json({ status: 'error', message: e.message }); + res.status(500).json({ status: 'error', message: sanitizeError(e.message) }); } }); @@ -179,7 +179,7 @@ const isSuccess = data.status === "Success" || (data.status && typeof data.status === 'string' && data.status.toLowerCase() === "success"); if (isSuccess) { if (data.responseData && (data.responseData.status === "Failure" || data.responseData.message === "No Records Found")) { - return res.status(400).json({ status: 'error', message: data.responseData.message || "No Records Found", details: data }); + return res.status(400).json({ status: 'error', message: sanitizeError(data.responseData.message || "No Records Found"), details: data }); } if (!data.responseData || !data.responseData.otpSent) { return res.status(400).json({ status: 'error', message: 'Invalid Captcha or OTP not sent', details: data }); @@ -190,9 +190,9 @@ if (data.errorDetails && data.errorDetails.messageEnglish) errMsg = data.errorDetails.messageEnglish; else if (data.message) errMsg = data.message; - res.status(400).json({ status: 'error', message: errMsg, details: data }); - } catch (e) { - res.status(500).json({ status: 'error', message: e.message }); + res.status(400).json({ status: 'error', message: sanitizeError(errMsg), details: data }); + } catch (e) { + res.status(500).json({ status: 'error', message: sanitizeError(e.message) }); } }); @@ -226,9 +226,9 @@ else if (data.errorDetails && data.errorDetails.messageEnglish) errMsg = data.errorDetails.messageEnglish; else if (data.message) errMsg = data.message; - res.status(400).json({ status: 'error', message: errMsg, details: data }); - } catch (e) { - res.status(500).json({ status: 'error', message: e.message }); + res.status(400).json({ status: 'error', message: sanitizeError(errMsg), details: data }); + } catch (e) { + res.status(500).json({ status: 'error', message: sanitizeError(e.message) }); } }); @@ -255,9 +255,9 @@ if (data.errorDetails && data.errorDetails.messageEnglish) errMsg = data.errorDetails.messageEnglish; else if (data.messageEnglish) errMsg = data.messageEnglish; - res.status(400).json({ status: 'error', message: errMsg, details: data }); - } catch (e) { - res.status(500).json({ status: 'error', message: e.message }); + res.status(400).json({ status: 'error', message: sanitizeError(errMsg), details: data }); + } catch (e) { + res.status(500).json({ status: 'error', message: sanitizeError(e.message) }); } }); @@ -296,9 +296,9 @@ pdfBase64: Buffer.from(unlockedBytes).toString('base64') }); } - res.status(400).json({ status: 'error', message: data.message || "PDF not generated" }); - } catch (e) { - res.status(500).json({ status: 'error', message: e.message }); + res.status(400).json({ status: 'error', message: sanitizeError(data.message || "PDF not generated") }); + } catch (e) { + res.status(500).json({ status: 'error', message: sanitizeError(e.message) }); } }); [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.